Interface URLRoute

A route representing an URL.

Hierarchy

Properties

Methods

Properties

dir: boolean

Whether this is a route to directory.

path: readonly URLEntry[]

A path split onto URL entries.

url: URL

URL this route represents, except for the pathname.

Intended to be immutable.

Methods

  • Extracts a section of this route between the given entry indices.

    When segment starts from the beginning of the route (i.e. from === 0), its URL retains protocol, host, port, user, and password. Otherwise segment's URL path becomes relative to route:/ one.

    When segment ends at the last path entry (i.e. to is absent or equal to path length), its URL retains search parameters. Otherwise they are removed.

    Parameters

    • fromEntry: number

      Zero-based index at which to start extraction. A negative index is treated as zero.

    • Optional toEntry: number

      Zero-based index before which to end extraction. An absent value or the value greater than the path length is treated as equal to path length. If this value is less than from, an empty route is returned.

    Returns URLRoute

    Either a route section, or this route if section has the same length.

  • Builds a string representation of the route path.

    Returns string

    URL-encoded pathname without leading / and extra parts. E.g. without search parameters.

  • Builds a string representation of this route.

    Returns string

    Raw URL pathname without leading / with URL search parameters if present.

Generated using TypeDoc