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:
parent
1b213bea58
commit
8cc77e719f
@ -42,7 +42,7 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
|
||||
}
|
||||
|
||||
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)});
|
||||
|
||||
return MessageResponse.SYNCHRONOUS;
|
||||
|
@ -37,9 +37,7 @@ requestAnalyzer.isValidCandidate = function (requestDetails, tabDetails) {
|
||||
initiatorDomain = Address.EXAMPLE;
|
||||
}
|
||||
|
||||
wildcard = helpers.getWildcard(initiatorDomain);
|
||||
isAllowlisted = requestAnalyzer.allowlistedDomains[initiatorDomain] || requestAnalyzer.allowlistedDomains[wildcard];
|
||||
|
||||
isAllowlisted = helpers.checkAllowlisted(initiatorDomain);
|
||||
if (isAllowlisted) {
|
||||
return false;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ stateManager._domainIsListed = function (domain, listname) {
|
||||
allowlistRecord = requestAnalyzer.domainsManipulateDOM[domain];
|
||||
isAllowlisted = Boolean(allowlistRecord);
|
||||
} else {
|
||||
allowlistRecord = requestAnalyzer.allowlistedDomains[domain] || requestAnalyzer.allowlistedDomains[helpers.getWildcard(domain)];
|
||||
allowlistRecord = helpers.checkAllowlisted(domain);
|
||||
isAllowlisted = Boolean(allowlistRecord);
|
||||
}
|
||||
|
||||
|
@ -89,13 +89,7 @@ helpers.languageIsFullySupported = function (language) {
|
||||
};
|
||||
|
||||
helpers.normalizeDomain = function (domain) {
|
||||
domain = domain.toLowerCase().trim();
|
||||
|
||||
if (domain.startsWith(Address.WWW_PREFIX)) {
|
||||
domain = domain.slice(Address.WWW_PREFIX.length);
|
||||
}
|
||||
|
||||
return domain;
|
||||
return domain.toLowerCase().trim();
|
||||
};
|
||||
|
||||
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) {
|
||||
let pathSegments, filename;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user