Fixes SAMSUNG update issue where blob.type === "" when adding image from gallery

This commit is contained in:
zsviczian 2025-02-04 20:07:47 +01:00 committed by GitHub
parent 424e94a403
commit 021f6d37d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -107,6 +107,17 @@ export const isImageFileHandle = (handle: FileSystemHandle | null) => {
return type === "png" || type === "svg";
};
const getExtensionFromFilename = (filename?: string): string | null => {
if (!filename) return null;
const ext = filename.split('.').pop()?.toLowerCase();
return ext || null;
};
const isSupportedExtension = (filename?: string) => {
const extension = getExtensionFromFilename(filename);
return !!extension && extension in IMAGE_MIME_TYPES;
};
export const isSupportedImageFileType = (type: string | null | undefined) => {
return !!type && (Object.values(IMAGE_MIME_TYPES) as string[]).includes(type);
};
@ -115,7 +126,11 @@ export const isSupportedImageFile = (
blob: Blob | null | undefined,
): blob is Blob & { type: ValueOf<typeof IMAGE_MIME_TYPES> } => {
const { type } = blob || {};
return isSupportedImageFileType(type);
if (type) {
return isSupportedImageFileType(type);
}
const { name } = blob || {};
return isSupportedExtension(name);
};
export const loadSceneOrLibraryFromBlob = async (