Skip to content

Commit 636b00a

Browse files
committed
fix(files): normalize mime type before icon matching
1 parent ea9d2ce commit 636b00a

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

apps/sim/components/icons/document-icons.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ describe('getDocumentIcon', () => {
99
expect(getDocumentIcon('application/x-zip-compressed', 'archive')).toBe(ZipIcon)
1010
})
1111

12+
it('ignores mime type casing and parameters', () => {
13+
expect(getDocumentIcon('APPLICATION/ZIP', 'archive')).toBe(ZipIcon)
14+
expect(getDocumentIcon('application/zip; charset=binary', 'archive')).toBe(ZipIcon)
15+
})
16+
1217
it('falls back to the default icon for unknown types', () => {
1318
expect(getDocumentIcon('application/octet-stream', 'blob.bin')).toBe(DefaultFileIcon)
1419
})

apps/sim/components/icons/document-icons.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,10 @@ export function DefaultFileIcon(props: SVGProps<SVGSVGElement>) {
259259
}
260260

261261
export function getDocumentIcon(
262-
mimeType: string,
262+
rawMimeType: string,
263263
filename: string
264264
): (props: SVGProps<SVGSVGElement>) => React.JSX.Element {
265+
const mimeType = rawMimeType.split(';')[0].trim().toLowerCase()
265266
const extension = filename.split('.').pop()?.toLowerCase()
266267

267268
if (

0 commit comments

Comments
 (0)