Skip to content

Commit 8b23339

Browse files
committed
fix infinite loop redirects
1 parent 1eb3f67 commit 8b23339

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/libs/redirect.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
import {config} from '@/client_config.js'
22

33
export 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
}

0 commit comments

Comments
 (0)