Spaces:
Build error
Build error
fix: meta charset hint
Browse files
src/services/snapshot-formatter.ts
CHANGED
|
@@ -827,6 +827,10 @@ ${suffixMixins.length ? `\n${suffixMixins.join('\n\n')}\n` : ''}`;
|
|
| 827 |
throw new AssertionFailureError(`Failed to access ${url}: file too large`);
|
| 828 |
}
|
| 829 |
snapshot.html = await readFile(await file.filePath, encoding);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 830 |
|
| 831 |
return snapshot;
|
| 832 |
}
|
|
|
|
| 827 |
throw new AssertionFailureError(`Failed to access ${url}: file too large`);
|
| 828 |
}
|
| 829 |
snapshot.html = await readFile(await file.filePath, encoding);
|
| 830 |
+
const innerCharset = snapshot.html.slice(0, 1024).match(/<meta[^>]+text\/html;\s*?charset=([^>"]+)\"/i)?.[1]?.toLowerCase();
|
| 831 |
+
if (innerCharset && innerCharset !== encoding) {
|
| 832 |
+
snapshot.html = await readFile(await file.filePath, innerCharset);
|
| 833 |
+
}
|
| 834 |
|
| 835 |
return snapshot;
|
| 836 |
}
|