Skip to content

Function: removeQueryParam()

ts
function removeQueryParam(url, key): string;

Removes a query parameter from a URL string.

Parameters

ParameterTypeDescription
urlstringThe source URL.
keystringThe query parameter name.

Returns

string

The updated URL string.

Example

ts
removeQueryParam('https://example.com?a=1&b=2', 'a')
// => 'https://example.com/?b=2'

Since

1.0.0

Released under the MIT License.