From 56df921a9b8bb988f226beb56cfbae012f2e9b6e Mon Sep 17 00:00:00 2001 From: Mathis Date: Mon, 30 Sep 2024 14:38:58 +0200 Subject: [PATCH] Refactor MIME type check in storage service Replace loop-based MIME type check with Set.prototype.has for improved readability and performance. This change eliminates the need for an explicit loop, making the code more concise and efficient. --- apps/backend/src/app/storage/storage.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/backend/src/app/storage/storage.service.ts b/apps/backend/src/app/storage/storage.service.ts index 534b31e..e56dabe 100644 --- a/apps/backend/src/app/storage/storage.service.ts +++ b/apps/backend/src/app/storage/storage.service.ts @@ -58,8 +58,7 @@ export class StorageService { * @return {boolean} - True if the current MIME type is allowed, false otherwise. */ function checkMime(allowedMime: Set, currentMime: string): boolean { - for (const mime of allowedMime) if (mime === currentMime) return true; - return false; + return allowedMime.has(currentMime); } const fileType = await FileType.fileTypeFromBuffer(file);