Skip to content

Commit

Permalink
fix: sanitize file name (#1728)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadoudicko authored Nov 27, 2023
1 parent a52b093 commit 914e5b2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frontend/lib/helpers/cloneFileWithSanitizedName.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const removeDiacriticsFromText = (input: string): string =>
input.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
const removeSpecialCharacters = (input: string) =>
input.normalize("NFD").replace(/[^\w\s.]/g, "");

export const cloneFileWithSanitizedName = (file: File): File => {
const sanitizedFileName = removeDiacriticsFromText(file.name);
const sanitizedFileName = removeSpecialCharacters(file.name);

return new File([file], sanitizedFileName, { type: file.type });
};

0 comments on commit 914e5b2

Please sign in to comment.