Skip to content

Commit 2a79a17

Browse files
committed
i
1 parent e5573a9 commit 2a79a17

7 files changed

Lines changed: 14 additions & 12 deletions

File tree

dist/404.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
const pathSegmentsToKeep = 0;
2929
const l = new URL(window.location);
3030
const decodedPath = decodeURIComponent(l.pathname);
31-
if (!decodedPath.includes('//')) {
31+
if (!decodedPath.includes('?/') && !l.search.startsWith('?/')) {
3232
const basePath = '/' + l.pathname.split('/').slice(1, 1 + pathSegmentsToKeep).join('/');
3333
const restPath = l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/');
34-
const newPath = basePath + (basePath.endsWith('/') ? '/' : '//') + restPath;
35-
window.location.replace(l.origin + newPath + l.search + l.hash);
34+
const newPath = basePath + (basePath.endsWith('/') ? '?/' : '/?/') + restPath.replace(/&/g, '~and~');
35+
const newSearch = l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '';
36+
window.location.replace(l.origin + newPath + newSearch + l.hash);
3637
}
3738
})();
3839
</script></head><body></body></html>

dist/bundle-9c596.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

dist/bundle-da1b5.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.html

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

src/404.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
const pathSegmentsToKeep = 0;
2929
const l = new URL(window.location);
3030
const decodedPath = decodeURIComponent(l.pathname);
31-
if (!decodedPath.includes('//') && !l.search.startsWith('//')) {
31+
if (!decodedPath.includes('?/') && !l.search.startsWith('?/')) {
3232
const basePath = '/' + l.pathname.split('/').slice(1, 1 + pathSegmentsToKeep).join('/');
3333
const restPath = l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/');
34-
const newPath = basePath + (basePath.endsWith('/') ? '/' : '//') + restPath;
35-
window.location.replace(l.origin + newPath + l.search + l.hash);
34+
const newPath = basePath + (basePath.endsWith('/') ? '?/' : '/?/') + restPath.replace(/&/g, '~and~');
35+
const newSearch = l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '';
36+
window.location.replace(l.origin + newPath + newSearch + l.hash);
3637
}
3738
})();
3839
</script></head><body></body></html>

src/js/github-pages.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// the single page app to route accordingly.
1212

1313
// Updated to modern syntax in 2024 for https://github.com/i1li/i
14-
if (window.location.search.startsWith('//')) {
15-
const decoded = window.location.search.slice(2);
16-
window.history.replaceState(null, null, window.location.origin + '/' + decoded + window.location.hash);
14+
if (window.location.search.startsWith('?/')) {
15+
const decoded = window.location.search.slice(1).split('&').map(s => s.replace(/~and~/g, '&')).join('?');
16+
window.history.replaceState(null, null, window.location.origin + decoded + window.location.hash);
1717
}

0 commit comments

Comments
 (0)