Skip to content

Commit 771eaf8

Browse files
Fix redirects
1 parent 7ffe38f commit 771eaf8

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

web/resources/404.html

+19-7
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,29 @@ <h1>Page not found</h1>
88
const path = window.location.pathname;
99

1010
// Transform the path: lowercase the first letter of each segment
11-
const newPath = path
11+
const pathLowSegments = path
1212
.split('/')
1313
.map(segment => segment ? segment[0].toLowerCase() + segment.slice(1) : '')
1414
.join('/');
1515

1616
// Redirect only if the transformed path is different from the current path
17-
if (newPath !== path) {
18-
window.location.replace(newPath);
19-
} else {
20-
// Show the 'not-found' element if no redirect is needed
21-
document.getElementById('pathname').textContent = path;
22-
document.getElementById('not-found').style.display = 'block';
17+
if (pathLowSegments !== path) {
18+
window.location.replace(pathLowSegments);
19+
return;
2320
}
21+
22+
// Redirect element/* to /*
23+
if (path.startsWith('/element/')) {
24+
const elementPath = path.slice('/element/'.length);
25+
if (elementPath === 'index.html') {
26+
return;
27+
}
28+
29+
window.location.replace('/' + elementPath);
30+
return;
31+
}
32+
33+
// Show the 'not-found' element if no redirect is needed
34+
document.getElementById('pathname').textContent = path;
35+
document.getElementById('not-found').style.display = 'block';
2436
</script>

web/resources/_redirects

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
/wiki/ /
22
/wiki/* /:splat
3-
4-
/element/* /:splat

0 commit comments

Comments
 (0)