UrlConfig | @uirouter/react
Options
All
  • Public
  • Public/Protected
  • All
Menu

An API to customize the URL behavior and retrieve URL configuration

This API is used to customize the behavior of the URL. This includes optional trailing slashes (strictMode), case sensitivity (caseInsensitive), and custom parameter encoding (custom type).

It also has information about the location (url) configuration such as port and baseHref. This information can be used to build absolute URLs, such as https://example.com:443/basepath/state/substate?param1=a#hashvalue;

This API is found at router.urlService.config (see: UIRouter.urlService, [[URLService.config]])

Hierarchy

  • UrlConfig

Implements

Index

Methods

baseHref

  • baseHref(): string

caseInsensitive

  • caseInsensitive(value?: boolean): boolean
  • Defines whether URL matching should be case sensitive (the default behavior), or not.

    Example:

    // Allow case insensitive url matches
    urlService.config.caseInsensitive(true);

    Parameters

    • Optional value: boolean

      false to match URL in a case sensitive manner; otherwise true;

    Returns boolean

    the current value of caseInsensitive

defaultSquashPolicy

  • defaultSquashPolicy(value?: boolean | string): string | false | true
  • Sets the default behavior when generating or matching URLs with default parameter values.

    Example:

    // Remove default parameter values from the url
    urlService.config.defaultSquashPolicy(true);

    Parameters

    • Optional value: boolean | string

      A string that defines the default parameter URL squashing behavior.

      • nosquash: When generating an href with a default parameter value, do not squash the parameter value from the URL
      • slash: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the parameter is surrounded by slashes, squash (remove) one slash from the URL
      • any other string, e.g. "~": When generating an href with a default parameter value, squash (remove) the parameter value from the URL and replace it with this string.

    Returns string | false | true

    the current value of defaultSquashPolicy

hashPrefix

  • hashPrefix(newprefix?: string): string
  • Gets or sets the hashPrefix

    This only applies when not running in html5Mode (pushstate mode)

    If the current url is http://localhost/app#!/uirouter/path/#anchor, it returns ! which is the prefix for the "hashbang" portion.

    Parameters

    • Optional newprefix: string

    Returns string

    the hash prefix

host

  • host(): string

html5Mode

  • html5Mode(): boolean

port

  • port(): number

protocol

  • protocol(): string

strictMode

  • strictMode(value?: boolean): boolean
  • Defines whether URLs should match trailing slashes, or not (the default behavior).

    Example:

    // Allow optional trailing slashes
    urlService.config.strictMode(false);

    Parameters

    • Optional value: boolean

      false to match trailing slashes in URLs, otherwise true.

    Returns boolean

    the current value of strictMode

type

Generated using TypeDoc