mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-22 17:39:12 +01:00
Handle quotes around charset
This commit is contained in:
@@ -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