remove mandatory www in URL

This commit is contained in:
Sherry Ma 2020-03-10 13:37:20 -04:00 committed by Martin D Kealey
parent a3f3413a01
commit e5d157e538
2 changed files with 6 additions and 14 deletions

View file

@ -1889,27 +1889,22 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
}, },
checkUrl(url){ checkUrl(url){
// append "https://" if protocol not found
const validUrl = /[\w.-]+(?:\.[\w.-]+)/g; const validUrl = /[\w.-]+(?:\.[\w.-]+)/g;
const regexWww = /.*www\..*/g; const regexProtocol = /^https?:\/\/.*/g;
const regexhttp = /^http:\/\/.*/g; const valid = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/g;
const regexhttps = /^https:\/\/.*/g;
let newURL = url; let newURL = url;
if (!url.match(validUrl)) { if (!url.match(validUrl)) {
return null; return null;
} }
if (!url.match(regexhttp) && !url.match(regexhttps)) { // append "https://" if protocol not found
if (!url.match(regexProtocol)) {
newURL = "https://" + url; newURL = "https://" + url;
} }
if (!url.match(regexWww)) { if (!newURL.match(valid)) {
if (newURL.match(regexhttp)) { return null;
newURL = "http://www." + newURL.substring(7);
} else if (newURL.match(regexhttps)) {
newURL = "https://www." + newURL.substring(8);
}
} }
return newURL; return newURL;
}, },

View file

@ -1,4 +1,3 @@
// const expect = require("chai").expect;
const {initializeWithTab} = require("../common"); const {initializeWithTab} = require("../common");
describe("#1670", function () { describe("#1670", function () {
@ -58,8 +57,6 @@ describe("#1670", function () {
}); });
it("should not assign the URL to a container", 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; this.webExt.background.browser.contextualIdentities.update.should.not.have.been.called;
}); });
}); });