Skip to content

The open source coding agent.

TypeScript

fix: locale routing

Adamba740eaefd42
diff --git a/packages/console/app/src/lib/language.ts b/packages/console/app/src/lib/language.ts
index a13692476c5..54321d23438 100644
--- a/packages/console/app/src/lib/language.ts
+++ b/packages/console/app/src/lib/language.ts
@@ -132,13 +132,15 @@ export function docs(locale: Locale, pathname: string) {
if (value === "root") return `${next.path}${next.suffix}`
- const hit = /^\/docs\/([^/]+)(\/.*)?$/.exec(next.path)
- if (hit && DOCS_SEGMENT.has(hit[1] ?? "")) {
- return `${next.path}${next.suffix}`
- }
-
if (next.path === "/docs") return `/docs/${value}${next.suffix}`
if (next.path === "/docs/") return `/docs/${value}/${next.suffix}`
+
+ const head = next.path.slice("/docs/".length).split("/")[0] ?? ""
+ if (!head) return `/docs/${value}/${next.suffix}`
+ if (DOCS_SEGMENT.has(head)) return `${next.path}${next.suffix}`
+ if (head.startsWith("_")) return `${next.path}${next.suffix}`
+ if (head.includes(".")) return `${next.path}${next.suffix}`
+
return `/docs/${value}${next.path.slice("/docs".length)}${next.suffix}`
}