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

Function normalizeDataPathname

packages/stats/app/src/lib/language.ts:26–36  ·  view source on GitHub ↗
(pathname: string)

Source from the content-addressed store, hash-verified

24export const baseUrl = "https://opencode.ai"
25
26function normalizeDataPathname(pathname: string) {
27 const next = localeStrip(pathname)
28 const path = next.startsWith("/") ? next : `/${next}`
29 const trailing = path.endsWith("/")
30 const segments = path.split("/").filter(Boolean)
31 const dataIndex = segments.lastIndexOf(basePath.slice(1))
32 const rest = dataIndex === -1 ? segments : segments.slice(dataIndex + 1)
33 const normalized = `${basePath}${rest.length ? `/${rest.join("/")}` : "/"}`
34 if (trailing && !normalized.endsWith("/")) return `${normalized}/`
35 return normalized
36}
37
38export function strip(pathname: string) {
39 return normalizeDataPathname(pathname)

Callers 2

stripFunction · 0.85
routeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected