File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,11 @@ const truncateFilename = (filename: string): string => {
2424 if ( filename . length <= MAX_FILENAME_LENGTH ) {
2525 return filename
2626 }
27- const ext = filename . split ( '.' ) . pop ( ) || ''
28- const nameWithoutExt = filename . slice ( 0 , filename . length - ext . length - 1 )
29- const truncatedName = nameWithoutExt . slice (
30- 0 ,
31- MAX_FILENAME_LENGTH - ext . length - 4 ,
32- )
33- return `${ truncatedName } …${ ext ? '.' + ext : '' } `
27+ const lastDot = filename . lastIndexOf ( '.' )
28+ const ext = lastDot !== - 1 ? filename . slice ( lastDot ) : ''
29+ const baseName = lastDot !== - 1 ? filename . slice ( 0 , lastDot ) : filename
30+ const maxBaseLength = MAX_FILENAME_LENGTH - ext . length - 1 // -1 for ellipsis
31+ return baseName . slice ( 0 , maxBaseLength ) + '…' + ext
3432}
3533
3634export interface ImageCardImage {
You can’t perform that action at this time.
0 commit comments