Fix history.replaceState
This commit is contained in:
@ -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 () {
|
||||
|
Reference in New Issue
Block a user