Skip to content

Commit

Permalink
fix(utils): extension should not contain dot in getMimeFromFileExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Jul 12, 2023
1 parent 012fe83 commit 7be3d0c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/uikit-utils/src/shared/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ export function getFileExtensionFromMime(mimeType?: string | null): string {
*/
export function getMimeFromFileExtension(ext?: string | null) {
if (!ext) return '';
return EXTENSION_MIME_MAP[ext.toLowerCase()] || '';

const sliceIdx = ext.lastIndexOf('.');
const extWithoutDot = sliceIdx === -1 ? ext : ext.slice(sliceIdx + 1);

return EXTENSION_MIME_MAP[extWithoutDot.toLowerCase()] || '';
}

/**
Expand Down

0 comments on commit 7be3d0c

Please sign in to comment.