1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 04:26:35 +02:00

Added support for wildcards (*) in domains

Fixes #613
This commit is contained in:
kkapsner 2022-04-26 17:08:28 +02:00
parent cfb09075eb
commit 4bd0c0c96c
4 changed files with 16 additions and 5 deletions

View file

@ -29,9 +29,12 @@
})
.map(function(entry){
let regExp;
const domain = !!entry.match(/^[A-Za-z0-9_.-]+$/);
const domain = !!entry.match(/^[A-Za-z0-9_.*-]+$/);
if (domain){
regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$", "i");
regExp = new RegExp(
"(?:^|\\.)" + entry.replace(/([\\+?[^\]$(){}=!|.])/g, "\\$1").replace(/\*/g, ".+") + "\\.?$",
"i"
);
}
else {
try {

View file

@ -166,10 +166,10 @@
function initializeUrlSetting(urlSetting){
let regExp;
const domain = !!urlSetting.url.match(/^[A-Za-z0-9_.-]+$/);
const domain = !!urlSetting.url.match(/^[A-Za-z0-9_.*-]+$/);
if (domain){
regExp = new RegExp(
"(?:^|\\.)" + urlSetting.url.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$",
"(?:^|\\.)" + urlSetting.url.replace(/([\\+?[^\]$(){}=!|.])/g, "\\$1").replace(/\*/g, ".+") + "\\.?$",
"i"
);
}