Skip to content

Commit

Permalink
some handlings
Browse files Browse the repository at this point in the history
  • Loading branch information
aakashdinkarh committed Oct 13, 2024
1 parent 8871887 commit 5ee7dfc
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,37 @@

var maxRedirects = 2;
var redirectCount = parseInt(sessionStorage.getItem('redirects')) || 0;
console.log(redirectCount);
if (redirectCount >= maxRedirects) {
sessionStorage.removeItem('redirects');
document.body.innerHTML = "<h1>404 Not Found</h1><p>The page you are looking for doesn't exist.</p>";
return;
}
sessionStorage.setItem('redirects', ++redirectCount);
var l = window.location;
l.replace(
l.protocol +
"//" +
l.hostname +
(l.port ? ":" + l.port : "") +
l.pathname
.split("/")
.slice(0, 1 + pathSegmentsToKeep)
.join("/") +
"/?/" +
l.pathname
.slice(1)
.split("/")
.slice(pathSegmentsToKeep)
.join("/")
.replace(/&/g, "~and~") +
(l.search ? "&" + l.search.slice(1).replace(/&/g, "~and~") : "") +
l.hash
);
console.log(redirectCount, 'inside');
// sessionStorage.removeItem('redirects');
} else {
sessionStorage.setItem('redirects', ++redirectCount);
var l = window.location;
l.replace(
l.protocol +
"//" +
l.hostname +
(l.port ? ":" + l.port : "") +
l.pathname
.split("/")
.slice(0, 1 + pathSegmentsToKeep)
.join("/") +
"/?/" +
l.pathname
.slice(1)
.split("/")
.slice(pathSegmentsToKeep)
.join("/")
.replace(/&/g, "~and~") +
(l.search ? "&" + l.search.slice(1).replace(/&/g, "~and~") : "") +
l.hash
);
}
</script>
</head>
<body></body>
<body>
<h1>404 Not Found</h1>
<p>The page you are looking for doesn't exist.</p>
</body>
</html>

0 comments on commit 5ee7dfc

Please sign in to comment.