Extract the pathname from a full URL string.
Convenience utility for use with URLs from RouteResolver.resolveUrlById or from a preload() Map.
preload()
A full URL string (e.g., "https://example.com/docs/setup")
"https://example.com/docs/setup"
The pathname portion (e.g., "/docs/setup"), or null if the URL is invalid.
"/docs/setup"
null
import { getPath } from '@sanity/routes'const urlMap = await resolver.preload()for (const [id, url] of urlMap) { const path = getPath(url) // → "/blog/hello-world"} Copy
import { getPath } from '@sanity/routes'const urlMap = await resolver.preload()for (const [id, url] of urlMap) { const path = getPath(url) // → "/blog/hello-world"}
Extract the pathname from a full URL string.
Convenience utility for use with URLs from RouteResolver.resolveUrlById or from a
preload()Map.