Skip to content

Commit

Permalink
fix: refactor conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocostadev committed Jun 13, 2024
1 parent 629c6c0 commit ab27344
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions apps/meteor/app/utils/lib/restrictions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const fileUploadMediaBlackList = function (customBlackList: string): string[] |
return blacklist.split(',').map((item) => item.trim());
};

const isTypeOnList = function (type: string, list: string[]): boolean | undefined {
const isTypeOnList = function (type?: string, list?: string[]): boolean {
if (!type || !list) {
return false;
}

if (list.includes(type)) {
return true;
}
Expand All @@ -29,6 +33,8 @@ const isTypeOnList = function (type: string, list: string[]): boolean | undefine
if (wildcards.includes(type.replace(/(\/.*)$/, wildCardGlob))) {
return true;
}

return false;
};

export const fileUploadIsValidContentTypeFromSettings = function (
Expand All @@ -43,12 +49,8 @@ export const fileUploadIsValidContentTypeFromSettings = function (
return false;
}

if (whiteList && type && isTypeOnList(type, whiteList)) {
return true;
}

if (!type && whiteList) {
return false;
if (whiteList) {
return isTypeOnList(type, whiteList);
}

if (!whiteList) {
Expand Down

0 comments on commit ab27344

Please sign in to comment.