@letsrunit/playwright 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/scrub-html.ts +12 -1
package/dist/index.js
CHANGED
|
@@ -68808,7 +68808,8 @@ var memoizedScrubHtml = memoize(realScrubHtml, {
|
|
|
68808
68808
|
});
|
|
68809
68809
|
async function realScrubHtml({ html, url }, opts = {}) {
|
|
68810
68810
|
const o = { ...getDefaults(html.length), ...opts };
|
|
68811
|
-
const
|
|
68811
|
+
const htmlForDom = preStripHtmlForJSDOM(html, o.dropHead);
|
|
68812
|
+
const dom = new JSDOM(htmlForDom, { url });
|
|
68812
68813
|
const doc = dom.window.document;
|
|
68813
68814
|
if (o.pickMain) pickMain(doc);
|
|
68814
68815
|
dropInfraAndSvg(doc, !!o.dropSvg);
|
|
@@ -68867,6 +68868,13 @@ function pickMain(doc) {
|
|
|
68867
68868
|
doc.body.appendChild(clone);
|
|
68868
68869
|
return true;
|
|
68869
68870
|
}
|
|
68871
|
+
function preStripHtmlForJSDOM(html, dropHead) {
|
|
68872
|
+
let out = html;
|
|
68873
|
+
if (dropHead) out = out.replace(/<head\b[\s\S]*?<\/head>/gi, "");
|
|
68874
|
+
out = out.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "");
|
|
68875
|
+
out = out.replace(/<link\b[^>]*\brel\s*=\s*["']?stylesheet["']?[^>]*>/gi, "");
|
|
68876
|
+
return out;
|
|
68877
|
+
}
|
|
68870
68878
|
function dropInfraAndSvg(doc, dropSvg) {
|
|
68871
68879
|
const toDrop = [...ALWAYS_DROP, dropSvg ? "svg" : ""].filter(Boolean).join(",");
|
|
68872
68880
|
if (!toDrop) return;
|