Fixes naked domains with no HTTPS lock and explicit port numbers not correctly matched in mapped MV3 DNR rules (issue #387).

This commit is contained in:
hackademix 2024-11-21 01:25:29 +01:00
parent 317b97ccce
commit cbc3c239f2
No known key found for this signature in database
GPG Key ID: 231A83AFDA9C2434
1 changed files with 9 additions and 4 deletions

View File

@ -70,9 +70,14 @@
}
function toUrlFilter(siteKey) {
let urlFilter = `|${siteKey.replace(/^§:/, '|')}`;
if (!urlFilter.replace(/^\w+:\/+/).includes("/")) {
urlFilter += "/";
// Note: using '^' instead of '/' as a terminator
// takes explicit port numbers in account
if (Sites.isSecureDomainKey(siteKey)) {
return `||${Sites.toggleSecureDomainKey(siteKey,false)}^`
}
let urlFilter = `||${siteKey}`;
if (!urlFilter.replace(/^[\w-]+:\/+/, "").includes("/")) {
urlFilter += '^';
}
return urlFilter;
}
@ -93,8 +98,8 @@
if (!policy || policy.equals(_lastPolicy)) {
return await updateTabs();
}
_lastPolicy = policy;
}
_lastPolicy = policy;
const Rules = {
// Using capitalized keys to allow DRY tricks with get/update methods