File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { config } from '@/client_config.js'
22
33export async function redirectToFullUrl ( ) {
4+ if ( document . title == "not found" ) {
5+ return
6+ }
47 const message_el = document . getElementById ( "message_404" )
58 message_el . innerText = "Redirecting"
69
710 const response = await fetch ( `${ config . base } /api/redirect` )
811 const redirects = await response . json ( )
912 let pathname = window . location . pathname . substring ( 1 )
1013 if ( pathname in redirects ) {
11- window . location . href = redirects [ pathname ] ;
14+ const new_url = redirects [ pathname ]
15+ if ( new_url ) {
16+ console . log ( `${ pathname } => "${ new_url } "` )
17+ window . location . href = new_url ;
18+ } else
19+ {
20+ window . location . href = "/" ;
21+ }
1222 } else {
23+ console . log ( `${ pathname } => not found` )
24+ document . title = "not found"
1325 message_el . innerText = "Page not found"
1426 }
1527}
You can’t perform that action at this time.
0 commit comments