diff --git a/apps/api/src/scraper/scrapeURL/engines/fetch/index.ts b/apps/api/src/scraper/scrapeURL/engines/fetch/index.ts index 64269048..687c8232 100644 --- a/apps/api/src/scraper/scrapeURL/engines/fetch/index.ts +++ b/apps/api/src/scraper/scrapeURL/engines/fetch/index.ts @@ -74,7 +74,7 @@ export async function scrapeURLWithFetch( const buf = Buffer.from(await x.arrayBuffer()); let text = buf.toString("utf8"); - const charset = (text.match(/charset=["']?(.+?)["']?>/) ?? [])[1] + const charset = (text.match(/]*charset\s*=\s*["']?([^"'\s\/>]+)/i) ?? [])[1] try { if (charset) { text = new TextDecoder(charset.trim()).decode(buf);