Handle quotes around charset

This commit is contained in:
Gregory Schier
2024-10-23 05:44:37 -07:00
parent 5de50c70c6
commit ff52ad5345

View File

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