Fix content type parsing exception

This commit is contained in:
Gregory Schier
2025-02-24 22:44:58 -08:00
parent 7e1da4395d
commit d297e92a5a

View File

@@ -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');
}
}