Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
irekponor committed Sep 22, 2024
1 parent b7f61fd commit 6534076
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
if (!currentPath.startsWith(basePath)) {
currentPath = basePath + currentPath;
}

// Append the flag for redirection prevention
var redirectFlag = "?redirect=true";

// Prevent redirect loops by appending a flag
if (!currentPath.includes("?redirect=true")) {
window.location.replace(currentPath + (currentPath.includes('?') ? '&' : '?') + 'redirect=true');
// Prevent redirect loops by checking the flag
if (!currentPath.includes(redirectFlag)) {
var newPath = currentPath + (currentPath.includes('?') ? '&' : '?') + 'redirect=true';
window.location.replace(newPath);
} else {
// If redirected, clear the query string from the URL
window.history.replaceState({}, "", currentPath.replace('?redirect=true', ''));
// If redirected, clear the flag and update the URL
var cleanPath = currentPath.replace(redirectFlag, '');
window.history.replaceState({}, "", cleanPath);
}
})();
</script>
Expand Down

0 comments on commit 6534076

Please sign in to comment.