Add EasyList filter support
This commit is contained in:
@@ -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"]
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user