Fixed wrong label for http: sites in contextual policy UI (thanks barbaz for reporting).

This commit is contained in:
hackademix 2022-02-20 09:05:35 +01:00
parent a703a075f4
commit d900caebc4
1 changed files with 6 additions and 4 deletions

View File

@ -624,18 +624,20 @@ var UI = (() => {
opt.textContent = label;
return opt;
}
let toLabel = site => {
let label = Sites.toExternal(site);
return label.includes(":") ? label : `${label}`;
};
for (let child; child = ctxSelect.firstChild;) child.remove();
ctxSelect.appendChild(entry("*", _("anySite")));
let ctxSites = row.perms.contextual;
if (this.mainDomain) {
let key = Sites.optimalKey(this.mainUrl);
ctxSelect.appendChild(entry(key, `${Sites.toExternal(key)}`)).selected = key === row.contextMatch;
ctxSelect.appendChild(entry(key, toLabel(key))).selected = key === row.contextMatch;
} else {
if (ctxSites) {
for (let [site, ctxPerms] of ctxSites.entries()) {
let label = Sites.toExternal(site);
if (!label.includes(":")) label = `${label}`;
ctxSelect.appendChild(entry(site, label)).selected === perms === ctxPerms;
ctxSelect.appendChild(entry(site, toLabel(site))).selected === perms === ctxPerms;
}
}
}