mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-18 06:28:25 +01:00
Handle quotes around charset
This commit is contained in:
1 parent
5de50c70c6
commit
ff52ad5345
1 file changed
+3
-1
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user