From 06f7c372b5bd2c3650afbe8a0b61289ba5a9e22d Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 24 Sep 2020 08:27:27 +0100 Subject: [PATCH] Extract the domain by properly parsing the instance URL --- src/script/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/script/index.js b/src/script/index.js index 3387cba..fdd609c 100644 --- a/src/script/index.js +++ b/src/script/index.js @@ -38,10 +38,16 @@ function add_instance(text, disabled, selected) { choose_instance.appendChild(opt); } +function parseUrl(url) { + const parser = document.createElement('a'); + parser.href = url; + return parser; +} + if (prefillInstance != null) { const url = normalizeUrl(prefillInstance); 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) {