Skip to content

Commit e4ccbab

Browse files
committed
i
1 parent d488197 commit e4ccbab

5 files changed

Lines changed: 7 additions & 5 deletions

File tree

dist/404.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
// Otherwise, leave pathSegmentsToKeep as 0.
2727
(() => {
2828
const pathSegmentsToKeep = 0;
29-
let l = new URL(window.location);
30-
if (!l.search.startsWith('?/')) {
29+
const l = new URL(window.location);
30+
// Only redirect if no '?/' anywhere - guards against repeated redirect on already-rewritten URL
31+
if (!l.pathname.includes('?/') && !l.search.startsWith('?/')) {
3132
const basePath = '/' + l.pathname.split('/').slice(1, 1 + pathSegmentsToKeep).join('/');
3233
const restPath = l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/');
3334
const newPath = basePath + (basePath.endsWith('/') ? '' : '/') + '?/' + restPath.replace(/&/g, '~and~');

dist/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/404.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
// Otherwise, leave pathSegmentsToKeep as 0.
2727
(() => {
2828
const pathSegmentsToKeep = 0;
29-
let l = new URL(window.location);
30-
if (!l.search.startsWith('?/')) {
29+
const l = new URL(window.location);
30+
// Only redirect if no '?/' anywhere - guards against repeated redirect on already-rewritten URL
31+
if (!l.pathname.includes('?/') && !l.search.startsWith('?/')) {
3132
const basePath = '/' + l.pathname.split('/').slice(1, 1 + pathSegmentsToKeep).join('/');
3233
const restPath = l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/');
3334
const newPath = basePath + (basePath.endsWith('/') ? '' : '/') + '?/' + restPath.replace(/&/g, '~and~');

0 commit comments

Comments
 (0)