Skip to content

Commit 10413f6

Browse files
committed
i
1 parent 966eaca commit 10413f6

5 files changed

Lines changed: 15 additions & 19 deletions

File tree

dist/404.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@
2727
(() => {
2828
const pathSegmentsToKeep = 0;
2929
let l = new URL(window.location);
30-
if (!l.search.startsWith('?/') && !l.search.startsWith('%3F/')) {
31-
const basePath = '/' + l.pathname.split('/').slice(1, 1 + pathSegmentsToKeep).join('/');
32-
const restPath = l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/');
33-
const newPath = basePath + (basePath.endsWith('/') ? '' : '/') + '?/' + restPath.replace(/&/g, '~and~');
34-
const newSearch = l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '';
35-
l.pathname = newPath;
36-
l.search = newSearch;
37-
window.location.replace(l.href);
38-
}
30+
l.replace(
31+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
32+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
33+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
34+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
35+
l.hash
36+
);
3937
})();
4038
</script></head><body></body></html>

dist/index.html

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

src/404.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@
2727
(() => {
2828
const pathSegmentsToKeep = 0;
2929
let l = new URL(window.location);
30-
if (!l.search.startsWith('?/') && !l.search.startsWith('%3F/')) {
31-
const basePath = '/' + l.pathname.split('/').slice(1, 1 + pathSegmentsToKeep).join('/');
32-
const restPath = l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/');
33-
const newPath = basePath + (basePath.endsWith('/') ? '' : '/') + '?/' + restPath.replace(/&/g, '~and~');
34-
const newSearch = l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '';
35-
l.pathname = newPath;
36-
l.search = newSearch;
37-
window.location.replace(l.href);
38-
}
30+
l.replace(
31+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
32+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
33+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
34+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
35+
l.hash
36+
);
3937
})();
4038
</script></head><body></body></html>

0 commit comments

Comments
 (0)