Skip to content

Commit

Permalink
adding optional chaining for allowedExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
suubi-joshua committed Oct 28, 2024
1 parent 9fbf8b4 commit 79b4aea
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ const FilePreview: React.FC<FilePreviewProps> = ({
(event: SyntheticEvent) => {
event.preventDefault();

const sanitizedFileName = allowedExtensions.reduce((name, ext) => {
const sanitizedFileName = allowedExtensions?.reduce((name, ext) => {
const regex = new RegExp(`\\.(${ext})+$`, 'i');
return name.replace(regex, '');
}, fileName);
}, fileName) || fileName;

onSaveFile?.({
...uploadedFile,
Expand Down

0 comments on commit 79b4aea

Please sign in to comment.