# Class UrlConfigProvider

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]])

- Defined in router/url/url-config.js:16

#####
Index

### Constructors

constructor

### Properties

$get
_defaultSquashPolicy
_isCaseInsensitive
_isStrictMode
paramTypes

### Methods

caseInsensitive
defaultSquashPolicy
strictMode
type

##
Constructors

### constructor

- new UrlConfigProvider(): UrlConfigProvider

- #### Returns UrlConfigProvider

  - Defined in router/url/url-config.js:17

##
Properties

### $get

$get: (() => any)[] = ...

- Defined in router/url/url-config.js:52

### _defaultSquashPolicy

_defaultSquashPolicy: boolean

- Defined in router/url/url-config.js:25
- Defined in router/url/url-config.js:102

### _isCaseInsensitive

_isCaseInsensitive: boolean

- Defined in router/url/url-config.js:21
- Defined in router/url/url-config.js:71

### _isStrictMode

_isStrictMode: boolean

- Defined in router/url/url-config.js:23
- Defined in router/url/url-config.js:119

### paramTypes

paramTypes: ParamTypes

- Defined in router/url/url-config.js:19

##
Methods

### caseInsensitive

- caseInsensitive(value): any

- Defines whether URL matching should be case sensitive (the default behavior), or not.

  #### Example:

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

  #### Parameters

  - value: any

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

  #### Returns any

  the current value of caseInsensitive

  - Defined in router/url/url-config.js:70

### defaultSquashPolicy

- defaultSquashPolicy(value): any

- 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

  - value: any

    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 any

  the current value of defaultSquashPolicy

  - Defined in router/url/url-config.js:92

### strictMode

- strictMode(value): any

- Defines whether URLs should match trailing slashes, or not (the default behavior).

  #### Example:

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

  #### Parameters

  - value: any

    `false` to match trailing slashes in URLs, otherwise `true`.

  #### Returns any

  the current value of strictMode

  - Defined in router/url/url-config.js:118

### type

- type(name, definition, definitionFn): any

- Creates and registers a custom [[ParamType]] object

  A custom parameter type can be used to generate URLs with typed parameters or custom encoding/decoding.

  #### Note: Register custom types before using them in a state definition.

  #### Example:

      // Encode object parameter as JSON string
      urlService.config.type('myjson', {
        encode: (obj) => JSON.stringify(obj),
        decode: (str) => JSON.parse(str),
        is: (val) => typeof(val) === 'object',
        pattern: /[^/]+/,
        equals: (a, b) => _.isEqual(a, b),
      });

  See [[ParamTypeDefinition]] for more examples

  #### Parameters

  - name: any

    The type name.

  - definition: any

    The type definition. See [[ParamTypeDefinition]] for information on the values accepted.

  - definitionFn: any

    A function that is injected before the app runtime starts. The result of this function should be a [[ParamTypeDefinition]]. The result is merged into the existing `definition`. See [[ParamType]] for information on the values accepted.

  #### Returns any

  if only the `name` parameter was specified: the currently registered [[ParamType]] object, or undefined

  - Defined in router/url/url-config.js:151