From 071c21797ea63d9a687793873ea3238e022fb35a Mon Sep 17 00:00:00 2001 From: Ovidijus Parsiunas Date: Sun, 19 May 2024 23:52:39 +0100 Subject: [PATCH] updating the image file detection utils for higher usability --- component/src/views/chat/messages/fileMessageUtils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/component/src/views/chat/messages/fileMessageUtils.ts b/component/src/views/chat/messages/fileMessageUtils.ts index 173c3fff6..2f7264d1a 100644 --- a/component/src/views/chat/messages/fileMessageUtils.ts +++ b/component/src/views/chat/messages/fileMessageUtils.ts @@ -87,8 +87,12 @@ export class FileMessageUtils { } public static isImageFile(fileData: MessageFile) { - const imageRegex = /\.(jpg|jpeg|png|gif|bmp)$/i; const {type, src} = fileData; - return type === 'image' || src?.startsWith('data:image') || (src && imageRegex.test(src)); + return type === 'image' || src?.startsWith('data:image') || (src && FileMessageUtils.isImageFileExtension(src)); + } + + public static isImageFileExtension(fileName: string) { + const imageRegex = /\.(jpg|jpeg|png|gif|bmp)$/i; + return imageRegex.test(fileName); } }