Improved file: directory path normalization.

This commit is contained in:
hackademix 2020-09-28 22:38:27 +02:00
parent e62ac1d684
commit d802bf226f
1 changed files with 7 additions and 2 deletions

View File

@ -30,16 +30,21 @@
if (!ns.canScript) {
setTimeout(() => DocumentFreezer.unfreeze(), 0);
let normalizeDir = () => {
let normalizeDir = e => {
// Chromium does this automatically. We need it to understand we're a directory earlier and allow browser UI scripts.
if (document.baseURI === document.URL + "/") {
if (e) {
document.removeEventListener(e.type, normalizeDir);
e.stopImmediatePropagation();
}
window.stop();
location.replace(document.baseURI);
}
}
if (DocumentFreezer.firedDOMContentLoaded) {
normalizeDir();
} else {
addEventListener("readystatechange", normalizeDir);
document.addEventListener("readystatechange", normalizeDir);
}
return;
}