Skip to content

Commit

Permalink
updating the image file detection utils for higher usability
Browse files Browse the repository at this point in the history
  • Loading branch information
OvidijusParsiunas committed May 19, 2024
1 parent fdf550e commit 071c217
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions component/src/views/chat/messages/fileMessageUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 071c217

Please sign in to comment.