Skip to content

Commit 1260f48

Browse files
adamdotdevinBenGu3
authored andcommitted
refactor(stats): simplify locale prefix stripping
1 parent ed4a090 commit 1260f48

1 file changed

Lines changed: 1 addition & 24 deletions

File tree

packages/stats/app/src/app.tsx

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,9 @@ import { FileRoutes } from "@solidjs/start/router"
44
import { Suspense } from "solid-js"
55
import "./app.css"
66

7-
const localePrefixes = new Set([
8-
"ar",
9-
"br",
10-
"da",
11-
"de",
12-
"es",
13-
"fr",
14-
"it",
15-
"ja",
16-
"ko",
17-
"no",
18-
"pl",
19-
"ru",
20-
"th",
21-
"tr",
22-
"uk",
23-
"zh",
24-
"zht",
25-
])
26-
277
function stripLocaleDataPrefix(pathname: string) {
288
const value = pathname.startsWith("/") ? pathname : `/${pathname}`
29-
const segments = value.split("/")
30-
if (segments[2] !== "data") return value
31-
if (!localePrefixes.has(segments[1] ?? "")) return value
32-
return value.slice((segments[1]?.length ?? 0) + 1) || "/"
9+
return value.replace(/^\/[^/]+(?=\/data(?:\/|$))/, "")
3310
}
3411

3512
function AppMeta() {

0 commit comments

Comments
 (0)