Fix duplicate basePath in version navigation

router.push already handles basePath automatically, so using addBasePath
or including basePath in pathname caused double /entdb/entdb/ paths.
This commit is contained in:
cc
2026-04-15 02:01:15 +02:00
parent e1f47892da
commit e14355fb69
2 changed files with 5 additions and 5 deletions
+1 -3
View File
@@ -126,9 +126,7 @@ export default function BinaryDetail() {
const switchVersion = (versionTag: string) => {
router.push(
addBasePath(
`/os/bin?os=${encodeURIComponent(group + "/" + versionTag)}&path=${encodeURIComponent(path!)}`
)
`/os/bin?os=${encodeURIComponent(group + "/" + versionTag)}&path=${encodeURIComponent(path!)}`
);
};
+4 -2
View File
@@ -12,7 +12,7 @@ import { Input } from "@/components/ui/input";
import { ChevronDown, Check } from "lucide-react";
import type { OS } from "@/lib/types";
import { addBasePath } from "@/lib/env";
import { addBasePath, basePath } from "@/lib/env";
function compareVersion(a: string, b: string) {
const l1 = a.split(".").map(Number);
@@ -64,7 +64,9 @@ export function VersionSwitcher({ currentOs }: { currentOs: string }) {
const newParams = new URLSearchParams(searchParams.toString());
newParams.set("os", `${group}/${newTag}`);
router.push(`${pathname}?${newParams.toString()}`);
// Strip basePath from pathname since router.push adds it automatically
const pathWithoutBase = pathname.startsWith(basePath) ? pathname.slice(basePath.length) : pathname;
router.push(`${pathWithoutBase}?${newParams.toString()}`);
setOpen(false);
setFilter("");
};