Skip to content

Commit 7be3d0c

Browse files
committed
fix(utils): extension should not contain dot in getMimeFromFileExtension
1 parent 012fe83 commit 7be3d0c

File tree

1 file changed

+5
-1
lines changed
  • packages/uikit-utils/src/shared

1 file changed

+5
-1
lines changed

packages/uikit-utils/src/shared/file.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ export function getFileExtensionFromMime(mimeType?: string | null): string {
168168
*/
169169
export function getMimeFromFileExtension(ext?: string | null) {
170170
if (!ext) return '';
171-
return EXTENSION_MIME_MAP[ext.toLowerCase()] || '';
171+
172+
const sliceIdx = ext.lastIndexOf('.');
173+
const extWithoutDot = sliceIdx === -1 ? ext : ext.slice(sliceIdx + 1);
174+
175+
return EXTENSION_MIME_MAP[extWithoutDot.toLowerCase()] || '';
172176
}
173177

174178
/**

0 commit comments

Comments
 (0)