File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff 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 >
Original file line number Diff line number Diff line change 11/wiki/ /
22/wiki/* /:splat
3-
4- /element/* /:splat
You can’t perform that action at this time.
0 commit comments