appendQueryParam

Append a query parameter to a URL without replacing existing values of the same name, returning a new URL string with the value added.

Usage

appendQueryParam appends a query parameter to a URL without overwriting existing values of the same key.

import { appendQueryParam } from '@movk/core'

appendQueryParam('https://example.com?tag=a', 'tag', 'b')
// 'https://example.com?tag=a&tag=b'

API

appendQueryParam(url, key, value)

Append a query parameter without replacing existing values of the same name.

Parameters

url
string required
The URL string.
key
string required
The parameter key.
value
QueryParamValue required
The parameter value.

Returns

returns
string
A new URL string with the parameter appended.

Changelog

No recent changes
Copyright © 2024 - 2026 YiXuan - MIT License