Skip to content

Commit

Permalink
my own fix - should be final
Browse files Browse the repository at this point in the history
  • Loading branch information
aakashdinkarh committed Oct 13, 2024
1 parent 5ee7dfc commit c982977
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions 404.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<!-- Required for react projects hosted on portfolio domain to resolve the refresh nested route error when project is using react router -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<head>
<meta charset="utf-8" />
<title>404 Not Found</title>
<script type="text/javascript">
var reactProjectsWithRouter = ['the-movie-db', 'music-player-project'];
var pathSegmentsToKeep = 1;

var maxRedirects = 2;
var redirectCount = parseInt(sessionStorage.getItem('redirects')) || 0;
console.log(redirectCount);
if (redirectCount >= maxRedirects) {
console.log(redirectCount, 'inside');
// sessionStorage.removeItem('redirects');
} else {
sessionStorage.setItem('redirects', ++redirectCount);
var l = window.location;
var l = window.location;
if (reactProjectsWithRouter.includes(l.pathname.split('/')[1])) {
l.replace(
l.protocol +
"//" +
Expand All @@ -30,9 +24,7 @@
.slice(1)
.split("/")
.slice(pathSegmentsToKeep)
.join("/")
.replace(/&/g, "~and~") +
(l.search ? "&" + l.search.slice(1).replace(/&/g, "~and~") : "") +
.join("/") +
l.hash
);
}
Expand Down

0 comments on commit c982977

Please sign in to comment.