Fix path changer

This commit is contained in:
Half-Shot 2022-03-30 11:44:13 +01:00
parent de2528e75b
commit c90495277d

View File

@ -28,8 +28,12 @@ window.addEventListener("load", () => {
selectElement.add(option); selectElement.add(option);
selectElement.addEventListener('change', (event) => { selectElement.addEventListener('change', (event) => {
const versionlessPath = window.location.pathname.split('/').slice(2).join('/'); const path = [
window.location = `${window.location.origin}/${event.target.value}/${versionlessPath}`; ...window.location.pathname.split('/').slice(0, 2),
event.target.value,
...window.location.pathname.split('/').slice(3)].join('/')
].join('/');
window.location = `${window.location.origin}${path}`;
}); });
document.querySelector(".version-box").appendChild(selectElement); document.querySelector(".version-box").appendChild(selectElement);