Uri class
Class that represents a Uri and allows parsing/getting and setting of individual parts
Uri(string, IUri |
Create a new Uri. |
absolute |
Get the absolute uri string for this Uri |
hash |
The hash string of the uri |
host | The uri hostname (does not include port or scheme) |
no |
If true, do not emit the "//" separator after the scheme: Set to true for schemes like mailto (e.g. mailto:foo@bar) |
path | The relative path of the uri |
port | The port number of the uri as supplied in the url. 0 if left out in the url (e.g. the default port for the scheme). |
query |
The array of query parameters in the uri |
query |
Get the query string for this Uri. |
scheme | The uri scheme such as http or https |
add |
Adds a query string parameter to the current uri |
add |
Adds query string parameters to the current uri |
get |
Gets the effective port number, returning the default port number if omitted for the given scheme. |
get |
Get the value of the query parameter with the given key |
remove |
Removes a query string parameter |
Create a new Uri.
new Uri(uri?: string, options?: IUriParseOptions)
Parameters
- uri
-
string
Optional uri string to populate values with
- options
- IUriParseOptions
Options for parsing the uri string
Get the absolute uri string for this Uri
string absoluteUri
Property Value
string
The hash string of the uri
public hashString: string = ""
Property Value
string
The uri hostname (does not include port or scheme)
public host: string = ""
Property Value
string
If true, do not emit the "//" separator after the scheme: Set to true for schemes like mailto (e.g. mailto:foo@bar)
public noSchemeSeparator: boolean = false
Property Value
boolean
The relative path of the uri
public path: string = ""
Property Value
string
The port number of the uri as supplied in the url. 0 if left out in the url (e.g. the default port for the scheme).
public port: number = 0
Property Value
number
The array of query parameters in the uri
public queryParameters: IQueryParameter[] = []
Property Value
Get the query string for this Uri.
string queryString
Property Value
string
The uri scheme such as http or https
public scheme: string = ""
Property Value
string
Adds a query string parameter to the current uri
function addQueryParam(name: string, value: null | string, replaceExisting?: boolean)
Parameters
- name
-
string
The Query parameter name
- value
-
null | string
The Query parameter value
- replaceExisting
-
boolean
If true, replace all existing parameters with the same name
Adds query string parameters to the current uri
function addQueryParams(parameters: {[key: string]: QueryParameterValueType}, replaceExisting?: boolean, keyPrefix?: string)
Parameters
- parameters
-
{[key: string]: QueryParameterValueType}
Query parameters to add
- replaceExisting
-
boolean
If true, replace all existing parameters with the same name
- keyPrefix
-
string
If specified, a value to prepend to all query parameter keys
Gets the effective port number, returning the default port number if omitted for the given scheme.
function getEffectivePort(): number
Returns
number
Get the value of the query parameter with the given key
function getQueryParam(name: string): undefined | null | string
Parameters
- name
-
string
Query parameter name
Returns
undefined | null | string
Removes a query string parameter
function removeQueryParam(name: string)
Parameters
- name
-
string
The Query parameter name