1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2025-02-02 04:16:59 +01:00

Fixed: WWW Prefix (#233)

This commit is contained in:
nobody 2021-01-18 19:05:41 +01:00
parent 1b213bea58
commit 8cc77e719f
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
4 changed files with 16 additions and 12 deletions

View File

@ -42,7 +42,7 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
} }
if (topic === 'domain:fetch-is-allowlisted') { if (topic === 'domain:fetch-is-allowlisted') {
let allowlistRecord = requestAnalyzer.allowlistedDomains[value] || requestAnalyzer.allowlistedDomains[helpers.getWildcard(value)]; let allowlistRecord = helpers.checkAllowlisted(value);
sendResponse({'value': Boolean(allowlistRecord)}); sendResponse({'value': Boolean(allowlistRecord)});
return MessageResponse.SYNCHRONOUS; return MessageResponse.SYNCHRONOUS;

View File

@ -37,9 +37,7 @@ requestAnalyzer.isValidCandidate = function (requestDetails, tabDetails) {
initiatorDomain = Address.EXAMPLE; initiatorDomain = Address.EXAMPLE;
} }
wildcard = helpers.getWildcard(initiatorDomain); isAllowlisted = helpers.checkAllowlisted(initiatorDomain);
isAllowlisted = requestAnalyzer.allowlistedDomains[initiatorDomain] || requestAnalyzer.allowlistedDomains[wildcard];
if (isAllowlisted) { if (isAllowlisted) {
return false; return false;
} }

View File

@ -255,7 +255,7 @@ stateManager._domainIsListed = function (domain, listname) {
allowlistRecord = requestAnalyzer.domainsManipulateDOM[domain]; allowlistRecord = requestAnalyzer.domainsManipulateDOM[domain];
isAllowlisted = Boolean(allowlistRecord); isAllowlisted = Boolean(allowlistRecord);
} else { } else {
allowlistRecord = requestAnalyzer.allowlistedDomains[domain] || requestAnalyzer.allowlistedDomains[helpers.getWildcard(domain)]; allowlistRecord = helpers.checkAllowlisted(domain);
isAllowlisted = Boolean(allowlistRecord); isAllowlisted = Boolean(allowlistRecord);
} }

View File

@ -89,13 +89,7 @@ helpers.languageIsFullySupported = function (language) {
}; };
helpers.normalizeDomain = function (domain) { helpers.normalizeDomain = function (domain) {
domain = domain.toLowerCase().trim(); return domain.toLowerCase().trim();
if (domain.startsWith(Address.WWW_PREFIX)) {
domain = domain.slice(Address.WWW_PREFIX.length);
}
return domain;
}; };
helpers.extractDomainFromUrl = function (url, normalize) { helpers.extractDomainFromUrl = function (url, normalize) {
@ -137,6 +131,18 @@ helpers.getWildcard = function(initiatorDomain) {
}; };
helpers.checkAllowlisted = function(domain) {
let domainWithoutPrefix, wildcard, list;
if (domain.startsWith(Address.WWW_PREFIX)) {
domainWithoutPrefix = domain.slice(Address.WWW_PREFIX.length);
}
wildcard = helpers.getWildcard(domain);
list = requestAnalyzer.allowlistedDomains;
return list[domain] || list[domainWithoutPrefix] || list[wildcard] || list[domainWithoutPrefix];
};
helpers.extractFilenameFromPath = function (path) { helpers.extractFilenameFromPath = function (path) {
let pathSegments, filename; let pathSegments, filename;