File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -109,16 +109,16 @@ export class DocumentGroupStrategy implements BuilderStrategy {
109109function resolveCollisions ( docs : VersionRestDocument [ ] , field : 'fileId' | 'filename' ) : VersionRestDocument [ ] {
110110 const fileIdMap = groupBy ( docs , ( document ) => document [ field ] )
111111 return ( [ ...fileIdMap . values ( ) ] as VersionRestDocument [ ] [ ] ) . reduce ( ( acc , docs ) => {
112- const [ _ , ...rest ] = docs
113- rest . forEach ( ( document , index ) => { document [ field ] = addPostfix ( ` ${ index + 1 } ` , document [ field ] ) } )
112+ const [ _ , ...duplicates ] = docs
113+ duplicates . forEach ( ( document , index ) => { document [ field ] = rename ( document [ field ] , index ) } )
114114 return [ ...acc , ...docs ]
115115 } , [ ] as VersionRestDocument [ ] )
116116}
117117
118- function addPostfix ( postfix : string , fileName : string ) : string {
118+ function rename ( fileName : string , index : number ) : string {
119119 const nameParts = fileName . split ( '.' )
120120 const extension = nameParts . length > 1 ? nameParts [ nameParts ?. length - 1 ] : ''
121- const nameWithPostfix = `${ nameParts [ 0 ] } ${ postfix } `
121+ const nameWithPostfix = `${ nameParts [ 0 ] } ${ index + 1 } `
122122
123123 if ( extension ) {
124124 return `${ nameWithPostfix } .${ extension } `
You can’t perform that action at this time.
0 commit comments