From a2c11989f8d826a5b6141b6f48b0899f44840c83 Mon Sep 17 00:00:00 2001 From: Sho Sakuma Date: Mon, 9 Mar 2026 13:30:31 +0900 Subject: fix(docs): prevent double-slash URL in version switcher for root locale When currentLocale is empty (root locale), both isLocaleFirst and activeVersion incorrectly matched the empty first segment of pathSegments, producing paths like //v1 instead of /v1/. --- docs/.vitepress/theme/VersionSwitcher.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/.vitepress/theme/VersionSwitcher.vue b/docs/.vitepress/theme/VersionSwitcher.vue index e534426..d3ecd62 100644 --- a/docs/.vitepress/theme/VersionSwitcher.vue +++ b/docs/.vitepress/theme/VersionSwitcher.vue @@ -47,7 +47,8 @@ const activeVersion = computed(() => { const { currentVersion } = props.versioningPlugin; const segments = pathSegments.value; const locale = currentLocale.value; - const versionCandidate = segments[0] === locale ? segments[1] : segments[0]; + const hasLocalePrefix = locale !== '' && segments[0] === locale; + const versionCandidate = hasLocalePrefix ? segments[1] : segments[0]; return versionSet.value.has(versionCandidate) ? versionCandidate : currentVersion; }); @@ -64,7 +65,8 @@ const shouldShowCurrentVersion = computed( ); function isLocaleFirst(segments: string[]): boolean { - return segments[0] === currentLocale.value; + const locale = currentLocale.value; + return locale !== '' && segments[0] === locale; } function removeVersionSegments(segments: string[]): string[] { -- cgit v1.2.1