1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-03 12:06:31 +02:00

Fetch errors in URL regular expressions creation

Fixes #581
This commit is contained in:
kkapsner 2022-01-30 13:11:44 +01:00
parent 4c364a9a72
commit d4fc7027eb
2 changed files with 11 additions and 2 deletions

View file

@ -174,7 +174,16 @@
);
}
else {
regExp = new RegExp(urlSetting.url, "i");
try {
regExp = new RegExp(urlSetting.url, "i");
}
catch (error){
logging.error("Error in regular expression", urlSetting.url, error);
regExp = new RegExp(
"(?:^|\\.)" + urlSetting.url.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$",
"i"
);
}
}
const match = function(url){
if (!url){