The original URL string to modify.
The name of the query parameter to add or replace.
Optional
value: stringThe value of the query parameter. If omitted, the parameter is added without a value.
If true
, the function will not replace an existing parameter; it will append a new one instead. Defaults to false
.
The new URL string with the query parameter added or replaced.
Adds or replaces a query parameter in the given URL string.
If the parameter already exists and
noReplace
isfalse
, its value will be replaced. If the parameter does not exist, it will be appended to the query string. Ifvalue
isundefined
, the parameter will be added without a value (e.g.,?name
). The function preserves any hash fragment present in the original URL.