SUpport for protocol-only entries in UI.

This commit is contained in:
hackademix 2018-09-09 23:46:49 +02:00
parent 16d1b03062
commit 050aa8b83b
1 changed files with 11 additions and 6 deletions

View File

@ -590,16 +590,21 @@ var UI = (() => {
try { try {
url = new URL(site); url = new URL(site);
} catch (e) { } catch (e) {
let protocol = Sites.isSecureDomainKey(site) ? "https:" : "http:"; if (/^(\w+:)\/*$/.test(site)) {
let hostname = Sites.toggleSecureDomainKey(site, false); url = {protocol: RegExp.$1, hostname: "", origin: site, pathname:""};
url = {protocol, hostname, origin: `${protocol}://${site}`, pathname: "/"}; let hostname = Sites.toExternal(url.hostname);
debug("Lonely %o", url, Sites.isSecureDomainKey(siteMatch) || !hostname && url.protocol === "https:");
} else {
let protocol = Sites.isSecureDomainKey(site) ? "https:" : "http:";
let hostname = Sites.toggleSecureDomainKey(site, false);
url = {protocol, hostname, origin: `${protocol}://${site}`, pathname: "/"};
}
} }
let hostname = Sites.toExternal(url.hostname); let hostname = Sites.toExternal(url.hostname);
let domain = tld.getDomain(hostname); let domain = tld.getDomain(hostname);
if (!siteMatch) { if (!siteMatch) {
// siteMatch = url.protocol === "https:" ? Sites.secureDomainKey(domain) : site;
siteMatch = site; siteMatch = site;
} }
let secure = Sites.isSecureDomainKey(siteMatch); let secure = Sites.isSecureDomainKey(siteMatch);
@ -628,12 +633,12 @@ var UI = (() => {
row.querySelector(".domain").textContent = domain; row.querySelector(".domain").textContent = domain;
row.querySelector(".path").textContent = siteMatch.length > url.origin.length ? url.pathname : ""; row.querySelector(".path").textContent = siteMatch.length > url.origin.length ? url.pathname : "";
let httpsOnly = row.querySelector("input.https-only");
httpsOnly.checked = keyStyle === "full" || keyStyle === "secure";
} else { } else {
row._label = siteMatch; row._label = siteMatch;
urlContainer.querySelector(".full-address").textContent = siteMatch; urlContainer.querySelector(".full-address").textContent = siteMatch;
} }
let httpsOnly = row.querySelector("input.https-only");
httpsOnly.checked = keyStyle === "full" || keyStyle === "secure";
let presets = row.querySelectorAll("input.preset"); let presets = row.querySelectorAll("input.preset");
let idSuffix = `-${this.uiCount}-${sitesCount}`; let idSuffix = `-${this.uiCount}-${sitesCount}`;