🐛 fix(loop): trying to fix infinite loop on refresh

This commit is contained in:
eshanized
2024-12-25 10:38:40 +05:30
parent b657e6ffe2
commit 96a8d3bac0

View File

@@ -54,21 +54,25 @@
<script type="text/javascript"> <script type="text/javascript">
(function(l) { (function(l) {
if (l.search && l.search.startsWith('/')) { if (l.search && l.search.startsWith('/')) {
// Extract and clean up the query string
const decoded = l.search const decoded = l.search
.slice(1) // Remove the leading "/" .slice(1) // Remove the leading "/"
.split('&') // Split the query string .split('&') // Split the query string by "&"
.filter(Boolean) // Remove empty strings caused by consecutive "&"
.map(s => s.replace(/~and~/g, '&')) // Replace "~and~" with "&" .map(s => s.replace(/~and~/g, '&')) // Replace "~and~" with "&"
.join('?'); // Join the components with "?" .join('&'); // Join back with "&"
// Reconstruct the URL and replace the history entry
window.history.replaceState( window.history.replaceState(
null, null,
'', // The second argument is the title; an empty string keeps it unchanged '', // Keep the title unchanged
l.pathname.slice(0, -1) + decoded + l.hash // Build the new URL `${l.pathname.slice(0, -1)}${decoded ? `?${decoded}` : ''}${l.hash}` // Build the new URL
); );
} }
})(window.location); })(window.location);
</script> </script>
</head> </head>
<body> <body>