Fix redirects in pages with other base paths than the default (/en/stable).

This commit is contained in:
Lukas Tenbrink
2026-01-16 12:41:29 +01:00
parent b6f12fcc41
commit bcc47750df

View File

@@ -38,7 +38,7 @@ Page not found
const currentPathSegments = window.location.pathname.split('/').filter(segment => segment !== '');
// Use the base path (e.g. "/en/latest") when available.
const currentBasePath = (currentPathSegments.length >= 2) ? ("/" + currentPathSegments.slice(0, 2).join("/")) : "/";
const currentBasePath = (currentPathSegments.length >= 2) ? ("/" + currentPathSegments.slice(0, 2).join("/")) : "";
fetch(currentBasePath + "/_static/redirects.csv")
.then(response => response.text())
@@ -54,7 +54,7 @@ Page not found
if (to.startsWith('https://')) {
window.location.replace(to);
} else {
const newUrl = window.location.href.replace(window.location.pathname, to);
const newUrl = window.location.href.replace(window.location.pathname, currentBasePath + to);
window.location.replace(newUrl);
}
}