refactor(stats): simplify locale prefix stripping
This commit is contained in:
@@ -4,32 +4,9 @@ import { FileRoutes } from "@solidjs/start/router"
|
|||||||
import { Suspense } from "solid-js"
|
import { Suspense } from "solid-js"
|
||||||
import "./app.css"
|
import "./app.css"
|
||||||
|
|
||||||
const localePrefixes = new Set([
|
|
||||||
"ar",
|
|
||||||
"br",
|
|
||||||
"da",
|
|
||||||
"de",
|
|
||||||
"es",
|
|
||||||
"fr",
|
|
||||||
"it",
|
|
||||||
"ja",
|
|
||||||
"ko",
|
|
||||||
"no",
|
|
||||||
"pl",
|
|
||||||
"ru",
|
|
||||||
"th",
|
|
||||||
"tr",
|
|
||||||
"uk",
|
|
||||||
"zh",
|
|
||||||
"zht",
|
|
||||||
])
|
|
||||||
|
|
||||||
function stripLocaleDataPrefix(pathname: string) {
|
function stripLocaleDataPrefix(pathname: string) {
|
||||||
const value = pathname.startsWith("/") ? pathname : `/${pathname}`
|
const value = pathname.startsWith("/") ? pathname : `/${pathname}`
|
||||||
const segments = value.split("/")
|
return value.replace(/^\/[^/]+(?=\/data(?:\/|$))/, "")
|
||||||
if (segments[2] !== "data") return value
|
|
||||||
if (!localePrefixes.has(segments[1] ?? "")) return value
|
|
||||||
return value.slice((segments[1]?.length ?? 0) + 1) || "/"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function AppMeta() {
|
function AppMeta() {
|
||||||
|
|||||||
Reference in New Issue
Block a user