Extract the domain by properly parsing the instance URL

This commit is contained in:
Andy Balaam 2020-09-24 08:27:27 +01:00
parent 303b0d1903
commit 06f7c372b5

View file

@ -38,10 +38,16 @@ function add_instance(text, disabled, selected) {
choose_instance.appendChild(opt); choose_instance.appendChild(opt);
} }
function parseUrl(url) {
const parser = document.createElement('a');
parser.href = url;
return parser;
}
if (prefillInstance != null) { if (prefillInstance != null) {
const url = normalizeUrl(prefillInstance); const url = normalizeUrl(prefillInstance);
instance.value = url; instance.value = url;
add_instance(url.slice(8, url.length - 1), false, true); add_instance(parseUrl(url).hostname, false, true);
} }
choose_instance.addEventListener('focus', function (e) { choose_instance.addEventListener('focus', function (e) {