Add EasyList filter support

This commit is contained in:
2026-05-16 22:07:39 -07:00
parent f4f1a7a78d
commit 46444b193b
12 changed files with 171818 additions and 228 deletions

View File

@@ -81,3 +81,25 @@ test("external asset reporting parses srcset-like attributes without splitting U
"https://media.example/photos/id/master/w_240,c_limit/photo.jpg"
]);
});
test("asset inliner skips URLs blocked by the filter hook", async () => {
const blocked = [];
const inliner = new AssetInliner({
shouldBlockAsset: (url, resourceType) => {
blocked.push([url, resourceType]);
return true;
}
});
const output = await inliner.inlineHtml(`
<link rel="stylesheet" href="https://ads.example/ad.css">
<img src="https://ads.example/ad.png">
`, "https://publisher.example/article");
assert.doesNotMatch(output, /ad\.css/);
assert.match(output, /data:image\/gif;base64/);
assert.deepEqual(blocked, [
["https://ads.example/ad.css", "stylesheet"],
["https://ads.example/ad.png", "image"]
]);
});