diff --git a/www/res/js/locutus.js b/www/res/js/locutus.js index dc18112..b10a7f5 100644 --- a/www/res/js/locutus.js +++ b/www/res/js/locutus.js @@ -33,15 +33,15 @@ function createLoginWindow() { function handleHash(hash) { if (hash[0] === '#') hash = hash.substr(1); - if (hash === '') hash = defaultLocation; switch (hash) { case "/welcome": createWelcomeWindow(); break; case "/login": createLoginWindow(); break; default: - console.error(`Invalid url hash "${hash}"`); - hash = defaultLocation; - break; + console.warn(`Invalid url hash #${hash}`); + history.replaceState(null, null, `#${defaultLocation}`); + handleHash(defaultLocation) + return; } let url = new URL(document.URL); @@ -50,12 +50,7 @@ function handleHash(hash) { } function handleUrl(url) { - let hash = new URL(url).hash; - if (hash === '') { - history.replaceState(null, null, `#${defaultLocation}`); - hash = defaultLocation; - } - handleHash(hash); + handleHash(new URL(url).hash); } window.addEventListener("load", function () {