Skip to content

Commit

Permalink
Rewrite formatFilename
Browse files Browse the repository at this point in the history
  • Loading branch information
chetbae committed Jul 12, 2023
1 parent d4beb30 commit 1bf88e2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Dashboard/upload_functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,8 @@ async function uploadManuscript(manuscript: File, currentFolder: IFolder, existi
}

export function formatFilename(filename: string, maxLen: number): string {
const chunkLen = Math.floor(maxLen/2);
const len = filename.length;
if (len <= maxLen) return filename;
else return `${filename.substring(0,chunkLen-1)}...${filename.substring(len-chunkLen+2, len)}`;
if (filename.length <= maxLen) return filename;
else return `${filename.substring(0,maxLen)}...`;
}

// Renames file if there are naming conflicts, in the form of 'foobar (1)'
Expand Down

0 comments on commit 1bf88e2

Please sign in to comment.