summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSho Sakuma <me@m1sk9.dev>2026-03-09 13:30:31 +0900
committerSho Sakuma <me@m1sk9.dev>2026-03-09 13:30:31 +0900
commita2c11989f8d826a5b6141b6f48b0899f44840c83 (patch)
treec1a595627c62b23c05622d59d801e70accc0af81 /docs
parent04c6a0899093e56552587bddf61256fe434ffebe (diff)
downloadLunaticChat-a2c11989f8d826a5b6141b6f48b0899f44840c83.tar.gz
LunaticChat-a2c11989f8d826a5b6141b6f48b0899f44840c83.tar.bz2
LunaticChat-a2c11989f8d826a5b6141b6f48b0899f44840c83.zip
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/.
Diffstat (limited to 'docs')
-rw-r--r--docs/.vitepress/theme/VersionSwitcher.vue6
1 files 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[] {