Skip to content

Commit

Permalink
fix(validation): skip client validation if mime type or file name are…
Browse files Browse the repository at this point in the history
…n't available
  • Loading branch information
nd0ut committed Jun 21, 2023
1 parent 33cf2f7 commit 0d7a96f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions blocks/FileItem/FileItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ export class FileItem extends UploaderBlock {
const mimeType = entry.getValue('mimeType');
const fileName = entry.getValue('fileName');

const needMimeCheck = !!mimeType;
const needExtCheck = !!fileName;
const mimeOk = needMimeCheck ? matchMimeType(mimeType, allowedFileTypes) : true;
const extOk = needExtCheck ? matchExtension(fileName, allowedFileTypes) : true;
if (!mimeType || !fileName) {
// Skip client validation if mime type or file name are not available for some reasons
return;
}

const mimeOk = matchMimeType(mimeType, allowedFileTypes);
const extOk = matchExtension(fileName, allowedFileTypes);

if (!mimeOk && !extOk) {
// Assume file type is not allowed if both mime and ext checks fail
Expand Down

0 comments on commit 0d7a96f

Please sign in to comment.