Skip to content

Commit

Permalink
Fix content type parsing exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gschier committed Feb 25, 2025
1 parent 7e1da43 commit d297e92
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src-web/lib/contentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit d297e92

Please sign in to comment.