Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusef Almamari committed Sep 25, 2024
1 parent c8edfe2 commit 5d210e5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
32 changes: 17 additions & 15 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@

var pathSegmentsToKeep = 0;

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
);
var location = window.location;

var newUrl =
location.protocol +
"//" +
location.hostname +
(location.port ? ":" + location.port : "") +
location.pathname
.split("/")
.slice(0, 1 + pathSegmentsToKeep)
.join("/") +
"/?/" +
location.pathname.slice(1).split("/").slice(pathSegmentsToKeep).join("/").replace(/&/g, "~and~") +
(location.search ? "&" + location.search.slice(1).replace(/&/g, "~and~") : "") +
location.hash;

location.replace(newUrl);
</script>
</head>
<body></body>
Expand Down
16 changes: 10 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@
* the browser to reload the page. This ensures that when the single page app loads,
* the correct URL is available in the browser's history for proper routing.
*/
(function (l) {
if (l.search[1] === "/") {
var decoded = l.search
(function (location) {
if (location.search[1] === "/") {
var decodedUrl = location.search
.slice(1)
.split("&")
.map(function (s) {
return s.replace(/~and~/g, "&");
.map(function (part) {
return part.replace(/~and~/g, "&");
})
.join("?");
window.history.replaceState(null, null, l.pathname.slice(0, -1) + decoded + l.hash);
window.history.replaceState(
null,
null,
location.pathname.slice(0, -1) + decodedUrl + location.hash
);
}
})(window.location);
</script>
Expand Down
Loading

0 comments on commit 5d210e5

Please sign in to comment.