Function: replaceQueryParam()
ts
function replaceQueryParam(
url,
key,
value): string;Replaces a query parameter value in a URL string.
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | The source URL. |
key | string | The query parameter name. |
value | string | The next query parameter value. |
Returns
string
The updated URL string.
Example
ts
replaceQueryParam('https://example.com?page=1', 'page', '2')
// => 'https://example.com/?page=2'Since
1.0.0