File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 11import { BlobReader , TextWriter , ZipReader } from '@zip.js/zip.js' ;
2+ import dayjs from './dates.js' ;
23import { diff , patch } from './diffs.js' ;
34
45export const REPLAY_FRAME_REGEX = / ^ ( [ 0 - 9 ] { 5 , 11 } ) ( i ? ) .j s o n $ / ;
@@ -197,3 +198,8 @@ export const loadReplayFromFile = async(file) => {
197198 await replay . _init ( ) ;
198199 return replay ;
199200} ;
201+
202+ export const filenameFromManifest = ( manifest , extension = 'zip' ) => {
203+ const startTime = dayjs ( manifest . startTime * 1000 ) ;
204+ return `${ startTime . format ( 'YYYY-MM-DD HH-mm' ) } ${ manifest . name } - ${ manifest . description } .${ extension } ` . replaceAll ( / [ \\ / ] / g, '_' ) ;
205+ } ;
Original file line number Diff line number Diff line change 1- import { createIframe } from '../replay.js' ;
1+ import { createIframe , filenameFromManifest } from '../replay.js' ;
22
33describe ( 'Replay module' , ( ) => {
44 describe ( 'creation of iframes' , ( ) => {
@@ -32,4 +32,17 @@ describe('Replay module', () => {
3232 expect ( iframe . messages [ 0 ] ) . toEqual ( [ 12345 , 'foo' , 'bar' ] ) ;
3333 } ) ;
3434 } ) ;
35+
36+ describe ( '#filenameFromManifest' , ( ) => {
37+ it ( 'suggests a filename' , ( ) => {
38+ const manifest = {
39+ startTime : new Date ( '2025-01-31 12:34:56 +00:00' ) . getTime ( ) / 1000 ,
40+ name : 'Service Name' ,
41+ description : 'Description with invalid/unwanted characters'
42+ } ;
43+
44+ const filename = filenameFromManifest ( manifest , 'ext' ) ;
45+ expect ( filename ) . toEqual ( '2025-01-31 12-34 Service Name - Description with invalid_unwanted characters.ext' ) ;
46+ } ) ;
47+ } ) ;
3548} ) ;
You can’t perform that action at this time.
0 commit comments