diff --git a/src/js/popup.js b/src/js/popup.js index 356d71a..5de34e0 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -1889,27 +1889,22 @@ Logic.registerPanel(P_CONTAINER_EDIT, { }, checkUrl(url){ - // append "https://" if protocol not found const validUrl = /[\w.-]+(?:\.[\w.-]+)/g; - const regexWww = /.*www\..*/g; - const regexhttp = /^http:\/\/.*/g; - const regexhttps = /^https:\/\/.*/g; + const regexProtocol = /^https?:\/\/.*/g; + const valid = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/g; let newURL = url; if (!url.match(validUrl)) { return null; } - if (!url.match(regexhttp) && !url.match(regexhttps)) { + // append "https://" if protocol not found + if (!url.match(regexProtocol)) { newURL = "https://" + url; } - if (!url.match(regexWww)) { - if (newURL.match(regexhttp)) { - newURL = "http://www." + newURL.substring(7); - } else if (newURL.match(regexhttps)) { - newURL = "https://www." + newURL.substring(8); - } + if (!newURL.match(valid)) { + return null; } return newURL; }, diff --git a/test/issues/1670.test.js b/test/issues/1670.test.js index fe8ae84..1fa71ba 100644 --- a/test/issues/1670.test.js +++ b/test/issues/1670.test.js @@ -1,4 +1,3 @@ -// const expect = require("chai").expect; const {initializeWithTab} = require("../common"); describe("#1670", function () { @@ -58,8 +57,6 @@ describe("#1670", function () { }); it("should not assign the URL to a container", function () { - // console.log(this.webExt.background.browser.contextualIdentities); - // expect( console.log.calledOnce ).to.be.true; this.webExt.background.browser.contextualIdentities.update.should.not.have.been.called; }); });