MCPcopy Create free account
hub / github.com/code-forge-io/react-router-devtools / splitSlug

Function splitSlug

docs/app/utils/split-slug.ts:1–16  ·  view source on GitHub ↗
(slug: string)

Source from the content-addressed store, hash-verified

1export function splitSlug(slug: string) {
2 const parts = slug.split("/").filter(Boolean)
3 if (parts.length === 2) {
4 const [section, filename] = parts
5 return { section, filename }
6 }
7
8 if (parts.length === 3) {
9 const [section, subsection, filename] = parts
10 return { section, subsection, filename }
11 }
12
13 throw new Error(
14 `Invalid slug format: expected "section/page" or "section/subsection/page" but got ${parts.length} segments — slug: ${slug}`
15 )
16}

Callers 3

buildDocPathFromSlugFunction · 0.90
buildSectionedToFunction · 0.90
buildDocHrefFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…