MCPcopy Create free account
hub / github.com/anomalyco/opencode / docsAlias

Function docsAlias

packages/web/src/middleware.ts:4–19  ·  view source on GitHub ↗
(pathname: string)

Source from the content-addressed store, hash-verified

2import { exactLocale, matchLocale } from "./i18n/locales"
3
4function docsAlias(pathname: string) {
5 const hit = /^\/docs\/([^/]+)(\/.*)?$/.exec(pathname)
6 if (!hit) return null
7
8 const value = hit[1] ?? ""
9 const tail = hit[2] ?? ""
10 const locale = exactLocale(value)
11 if (!locale) return null
12
13 const next = locale === "root" ? `/docs${tail}` : `/docs/${locale}${tail}`
14 if (next === pathname) return null
15 return {
16 path: next,
17 locale,
18 }
19}
20
21function cookie(locale: string) {
22 const value = locale === "root" ? "en" : locale

Callers 1

middleware.tsFile · 0.85

Calls 1

exactLocaleFunction · 0.90

Tested by

no test coverage detected