From 050aa8b83bf83b83ce76bf69112f4fd29b732ba8 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sun, 9 Sep 2018 23:46:49 +0200 Subject: SUpport for protocol-only entries in UI. --- src/ui/ui.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/ui.js b/src/ui/ui.js index 49d5dc1..4a9c7c8 100644 --- a/src/ui/ui.js +++ b/src/ui/ui.js @@ -590,16 +590,21 @@ var UI = (() => { try { url = new URL(site); } catch (e) { - let protocol = Sites.isSecureDomainKey(site) ? "https:" : "http:"; - let hostname = Sites.toggleSecureDomainKey(site, false); - url = {protocol, hostname, origin: `${protocol}://${site}`, pathname: "/"}; + if (/^(\w+:)\/*$/.test(site)) { + url = {protocol: RegExp.$1, hostname: "", origin: 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 domain = tld.getDomain(hostname); if (!siteMatch) { - // siteMatch = url.protocol === "https:" ? Sites.secureDomainKey(domain) : site; siteMatch = site; } let secure = Sites.isSecureDomainKey(siteMatch); @@ -628,12 +633,12 @@ var UI = (() => { row.querySelector(".domain").textContent = domain; 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 { row._label = 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 idSuffix = `-${this.uiCount}-${sitesCount}`; -- cgit v1.2.3