URLBuilder class

A class that handles creating, modifying, and parsing URLs.

Methods

appendPath(undefined | string)

Append the provided path to this URL's existing path. If the provided path contains a query, then it will be added to this URL as well.

getHost()

Get the host that has been set in this URL.

getPath()

Get the path that has been set in this URL.

getPort()

Get the port that has been set in this URL.

getQuery()

Get the query in this URL.

getQueryParameterValue(string)

Get the value of the query parameter with the provided query parameter name. If no query parameter exists with the provided name, then undefined will be returned.

getScheme()

Get the scheme that has been set in this URL.

parse(string)
replaceAll(string, string)

If the provided searchValue is found in this URLBuilder, then replace it with the provided replaceValue.

setHost(undefined | string)

Set the host for this URL. If the provided host contains other parts of a URL (such as a port, path, or query), those parts will be added to this URL as well.

setPath(undefined | string)

Set the path for this URL. If the provided path contains a query, then it will be added to this URL as well.

setPort(undefined | string | number)

Set the port for this URL. If the provided port contains other parts of a URL (such as a path or query), those parts will be added to this URL as well.

setQuery(undefined | string)

Set the query in this URL.

setQueryParameter(string, any)

Set a query parameter with the provided name and value in this URL's query. If the provided query parameter value is undefined or empty, then the query parameter will be removed if it existed.

setScheme(undefined | string)

Set the scheme/protocol for this URL. If the provided scheme contains other parts of a URL (such as a host, port, path, or query), those parts will be added to this URL as well.

toString()

Method Details

appendPath(undefined | string)

Append the provided path to this URL's existing path. If the provided path contains a query, then it will be added to this URL as well.

function appendPath(path: undefined | string)

Parameters

path

undefined | string

getHost()

Get the host that has been set in this URL.

function getHost(): undefined | string

Returns

undefined | string

getPath()

Get the path that has been set in this URL.

function getPath(): undefined | string

Returns

undefined | string

getPort()

Get the port that has been set in this URL.

function getPort(): undefined | string

Returns

undefined | string

getQuery()

Get the query in this URL.

function getQuery(): undefined | string

Returns

undefined | string

getQueryParameterValue(string)

Get the value of the query parameter with the provided query parameter name. If no query parameter exists with the provided name, then undefined will be returned.

function getQueryParameterValue(queryParameterName: string): undefined | string | string[]

Parameters

queryParameterName

string

Returns

undefined | string | string[]

getScheme()

Get the scheme that has been set in this URL.

function getScheme(): undefined | string

Returns

undefined | string

parse(string)

static function parse(text: string): URLBuilder

Parameters

text

string

Returns

replaceAll(string, string)

If the provided searchValue is found in this URLBuilder, then replace it with the provided replaceValue.

function replaceAll(searchValue: string, replaceValue: string)

Parameters

searchValue

string

replaceValue

string

setHost(undefined | string)

Set the host for this URL. If the provided host contains other parts of a URL (such as a port, path, or query), those parts will be added to this URL as well.

function setHost(host: undefined | string)

Parameters

host

undefined | string

setPath(undefined | string)

Set the path for this URL. If the provided path contains a query, then it will be added to this URL as well.

function setPath(path: undefined | string)

Parameters

path

undefined | string

setPort(undefined | string | number)

Set the port for this URL. If the provided port contains other parts of a URL (such as a path or query), those parts will be added to this URL as well.

function setPort(port: undefined | string | number)

Parameters

port

undefined | string | number

setQuery(undefined | string)

Set the query in this URL.

function setQuery(query: undefined | string)

Parameters

query

undefined | string

setQueryParameter(string, any)

Set a query parameter with the provided name and value in this URL's query. If the provided query parameter value is undefined or empty, then the query parameter will be removed if it existed.

function setQueryParameter(queryParameterName: string, queryParameterValue: any)

Parameters

queryParameterName

string

queryParameterValue

any

setScheme(undefined | string)

Set the scheme/protocol for this URL. If the provided scheme contains other parts of a URL (such as a host, port, path, or query), those parts will be added to this URL as well.

function setScheme(scheme: undefined | string)

Parameters

scheme

undefined | string

toString()

function toString(): string

Returns

string