From 8f8c2a24e423554ddafb67def4648991cb017fe2 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Fri, 12 May 2023 08:57:20 +0300 Subject: [PATCH] Fixed exclusions in a better way https://github.com/libredirect/browser_extension/issues/665 --- src/assets/javascripts/services.js | 9 ++++++++- src/pages/options/widgets/general.js | 4 ---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 37847a57..aa163451 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -821,7 +821,14 @@ async function copyRaw(url, test) { function isException(url) { let exceptions = options.exceptions if (exceptions && url) { - if (exceptions.url) for (const item of exceptions.url) if (item == url.href) return true + if (exceptions.url) { + for (let item of exceptions.url) { + item = new URL(item) + item = item.href + item = item.replace(/^http:\/\//, 'https://') + if (item == url.href) return true + } + } if (exceptions.regex) for (const item of exceptions.regex) if (new RegExp(item).test(url.href)) return true } return false diff --git a/src/pages/options/widgets/general.js b/src/pages/options/widgets/general.js index 3dd52af5..a046b26f 100644 --- a/src/pages/options/widgets/general.js +++ b/src/pages/options/widgets/general.js @@ -152,14 +152,10 @@ function calcExceptionsCustomInstances() { } calcExceptionsCustomInstances() document.getElementById("custom-exceptions-instance-form").addEventListener("submit", async event => { - console.log('something plz.... :\')') event.preventDefault() let val if (instanceType == "url" && nameCustomInstanceInput.validity.valid) { val = nameCustomInstanceInput.value - const url = new URL(val) - val = url.href - val = val.replace(/^http:\/\//, 'https://') if (!exceptionsCustomInstances.url.includes(val)) exceptionsCustomInstances.url.push(val) } else if (instanceType == "regex") { val = nameCustomInstanceInput.value