@sanity/routes
    Preparing search index...

    Function getPath

    • Extract the pathname from a full URL string.

      Convenience utility for use with URLs from RouteResolver.resolveUrlById or from a preload() Map.

      Parameters

      • url: string

        A full URL string (e.g., "https://example.com/docs/setup")

      Returns string | null

      The pathname portion (e.g., "/docs/setup"), or null if the URL is invalid.

      import { getPath } from '@sanity/routes'

      const urlMap = await resolver.preload()
      for (const [id, url] of urlMap) {
      const path = getPath(url)
      // → "/blog/hello-world"
      }