A codec for encoding and decoding URL parts.
API
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): { [k: string]: unknown; };
abstract encodeHash(hash: string): string;
abstract decodeHash(hash: string): string;
abstract normalize(href: string): string;
abstract normalize(path: string, search: { [k: string]: unknown; }, hash: string, baseUrl?: string | undefined): string;
abstract areEqual(valA: string, valB: string): boolean;
abstract parse(url: string, base?: string | undefined): { href: string; protocol: string; host: string; search: string; hash: string; hostname: string; port: string; pathname: string; };
}
encodePath
stringEncodes the path from the provided string
stringThe path string
string
decodePath
stringDecodes the path from the provided string
stringThe path string
string
encodeSearch
stringEncodes the search string from the provided string or object
string | { [k: string]: unknown; }
string
decodeSearch
{ [k: string]: unknown; }Decodes the search objects from the provided string
string
{ [k: string]: unknown; }
encodeHash
stringEncodes the hash from the provided string
string
string
decodeHash
stringDecodes the hash from the provided string
string
string
normalize
2 overloadsNormalizes the URL from the provided string
string
string
Normalizes the URL from the provided string, search, hash, and base URL parameters
stringThe URL path
{ [k: string]: unknown; }The search object
stringThe has string
string | undefinedThe base URL for the URL
string
areEqual
booleanChecks whether the two strings are equal
stringFirst string for comparison
stringSecond string for comparison
boolean
parse
{ href: string; protocol: string; host: string; search: string; hash: string; hostname: string; port: string; pathname: string; }Parses the URL string based on the base URL
stringThe full URL string
string | undefinedThe base for the URL
{ href: string; protocol: string; host: string; search: string; hash: string; hostname: string; port: string; pathname: string; }