Skip to content

Commit b9263ca

Browse files
committed
Updates
1 parent 2bac202 commit b9263ca

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

404.html

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,10 @@
1616
var query = window.location.search;
1717
var fragment = window.location.hash;
1818

19-
// If the path is not / and doesn't end with .html, redirect to /index.html
20-
// This is a more robust check to ensure we only redirect when necessary
21-
if (path !== '/' && !path.endsWith('.html') && !path.endsWith('/')) {
22-
// Store the original path in sessionStorage
23-
sessionStorage.setItem('redirectPath', path + query + fragment);
24-
// Redirect to index.html
19+
// Only redirect if not already on index.html and not a direct file request
20+
if (path !== '/index.html' && !path.endsWith('.html')) {
21+
window.history.replaceState(null, null, path + query + fragment);
2522
window.location.replace('/index.html');
26-
} else if (sessionStorage.getItem('redirectPath')) {
27-
// If we are on index.html and there's a stored redirectPath,
28-
// then replace the current history state with the stored path
29-
window.history.replaceState(null, null, sessionStorage.getItem('redirectPath'));
30-
sessionStorage.removeItem('redirectPath');
3123
}
3224
})();
3325
</script>

0 commit comments

Comments
 (0)