(pathname: string)
| 2 | import { exactLocale, matchLocale } from "./i18n/locales" |
| 3 | |
| 4 | function 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 | |
| 21 | function cookie(locale: string) { |
| 22 | const value = locale === "root" ? "en" : locale |
no test coverage detected