W3cubDocs

/Angular

UrlCodec

class

A codec for encoding and decoding URL parts.

abstract class UrlCodec {
  abstract encodePath(path: string): string
  abstract decodePath(path: string): string
  abstract encodeSearch(search: string | { [k: string]: unknown; }): string
  abstract decodeSearch(search: string): {...}
  abstract encodeHash(hash: string): string
  abstract decodeHash(hash: string): string
  abstract normalize(href: string): string
  abstract areEqual(valA: string, valB: string): boolean
  abstract parse(url: string, base?: string): {...}
}

Subclasses

Methods

Encodes the path from the provided string

abstract encodePath(path: string): string

Parameters
path string

The path string

Returns

string

Decodes the path from the provided string

abstract decodePath(path: string): string

Parameters
path string

The path string

Returns

string

Encodes the search string from the provided string or object

abstract encodeSearch(search: string | { [k: string]: unknown; }): string

Parameters
search string | { [k: string]: unknown; }
Returns

string

Decodes the search objects from the provided string

abstract decodeSearch(search: string): { [k: string]: unknown; }

Parameters
search string
Returns

`{

}`

Encodes the hash from the provided string

abstract encodeHash(hash: string): string

Parameters
hash string
Returns

string

Decodes the hash from the provided string

abstract decodeHash(hash: string): string

Parameters
hash string
Returns

string

Normalizes the URL from the provided string

abstract normalize(href: string): string

Parameters
href string
Returns

string

Normalizes the URL from the provided string, search, hash, and base URL parameters

abstract normalize(path: string, search: { [k: string]: unknown; }, hash: string, baseUrl?: string): string

Parameters
path string

The URL path

search object

The search object

hash string

The has string

baseUrl string

The base URL for the URL

Optional. Default is undefined.

Returns

string

Checks whether the two strings are equal

abstract areEqual(valA: string, valB: string): boolean

Parameters
valA string

First string for comparison

valB string

Second string for comparison

Returns

boolean

Parses the URL string based on the base URL

abstract parse(url: string, base?: string): { href: string; protocol: string; host: string; search: string; hash: string; hostname: string; port: string; pathname: string; }

Parameters
url string

The full URL string

base string

The base for the URL

Optional. Default is undefined.

Returns

{ href: string; protocol: string; host: string; search: string; hash: string; hostname: string; port: string; pathname: string; }

© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/common/upgrade/UrlCodec