mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-09-17 08:27:11 -04:00
Merge pull request #3463 from lightpanda-io/adblock-regex-pcre2
`AdBlocker`: run /regex/ filters with PCRE2
This commit is contained in:
8 files changed
+778
-65
No files matched your search
@@ -4390,12 +4390,27 @@ test "HttpClient: adblock verdicts apply per request" {
|
||||
\\||typed.example.com^$script
|
||||
\\||partied.example.com^$third-party
|
||||
\\||framed.example.com^$subdocument
|
||||
\\/\/[a-z]{4}\.js$/$match-case,script
|
||||
);
|
||||
try blocker.parse(&list);
|
||||
try blocker.build();
|
||||
client.network.adblocker = blocker;
|
||||
defer client.network.adblocker = null;
|
||||
|
||||
// A regex filter reads the URL as requested: case kept, fragment gone.
|
||||
try testing.expect(testIsUrlBlocked(&client, .{
|
||||
.url = "https://cdn.example.com/abcd.js",
|
||||
.resource_type = .script,
|
||||
}));
|
||||
try testing.expect(testIsUrlBlocked(&client, .{
|
||||
.url = "https://cdn.example.com/abcd.js#v2",
|
||||
.resource_type = .script,
|
||||
}));
|
||||
try testing.expect(!testIsUrlBlocked(&client, .{
|
||||
.url = "https://cdn.example.com/ABCD.js",
|
||||
.resource_type = .script,
|
||||
}));
|
||||
|
||||
try testing.expect(testIsUrlBlocked(&client, .{ .url = "https://ads.example.com/pixel.gif" }));
|
||||
// Hostnames are matched case-insensitively and without the port.
|
||||
try testing.expect(testIsUrlBlocked(&client, .{ .url = "https://SUB.ADS.EXAMPLE.COM:8443/x" }));
|
||||
|
||||
Reference in new issue
Block a user