Skip to content

Commit

Permalink
fix: add fallback value in sanitizeSpecialChar method return
Browse files Browse the repository at this point in the history
  • Loading branch information
diprodebnath committed Aug 12, 2024
1 parent 44f7d24 commit 383f839
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/server/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import slugify from "slugify";
import { nanoid } from "nanoid";

const sanitizeSpecialChar = (fileKey: string) => {
return fileKey.replace(/[^a-zA-Z0-9]/g, "");
const sanitizedString = fileKey.replace(/[^a-zA-Z0-9]/g, "");

if (!sanitizedString) {
return nanoid(10);
}
return sanitizedString;
};

type TgetS3PublicUrl = {
Expand Down

0 comments on commit 383f839

Please sign in to comment.