From d297e92a5aaba5a9908ff942573191d2d0db985c Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 24 Feb 2025 22:44:58 -0800 Subject: [PATCH] Fix content type parsing exception --- src-web/lib/contentType.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src-web/lib/contentType.ts b/src-web/lib/contentType.ts index 608362e2..c58a0fee 100644 --- a/src-web/lib/contentType.ts +++ b/src-web/lib/contentType.ts @@ -75,7 +75,10 @@ export function isProbablyTextContentType(contentType: string | null): boolean { ].some((textType) => normalized === textType || normalized.endsWith(textType)); } -export function getMimeTypeFromContentType(contentType: string) { - const mimeType = new MimeType(contentType); - return mimeType; +export function getMimeTypeFromContentType(contentType: string): MimeType { + try { + return new MimeType(contentType); + } catch { + return new MimeType('text/plain'); + } }