From ff52ad5345a3de744974523e704b13a7c3cf7037 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 23 Oct 2024 05:44:37 -0700 Subject: [PATCH] Handle quotes around charset --- src-web/lib/model_util.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src-web/lib/model_util.ts b/src-web/lib/model_util.ts index 78cd7ad6..4b8ab41e 100644 --- a/src-web/lib/model_util.ts +++ b/src-web/lib/model_util.ts @@ -58,5 +58,7 @@ export function getContentTypeHeader(headers: HttpResponseHeader[]): string | nu export function getCharsetFromContentType(headers: HttpResponseHeader[]): string | null { const contentType = getContentTypeHeader(headers); - return contentType?.match(/charset=([^ ;]+)/)?.[1] ?? null; + if (contentType == null) return null; + + return contentType.toLowerCase().match(/charset="?([^ ;"]+)"?/)?.[1] || null; }