kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
10 wiersze
311 B
TypeScript
10 wiersze
311 B
TypeScript
![]() |
export default (uri: string, key: string, value: string) => {
|
||
|
const re = new RegExp(`([?&])${key}=.*?(&|$)`, 'i')
|
||
|
if (uri.match(re)) {
|
||
|
return uri.replace(re, `$1${key}=${value}$2`)
|
||
|
} else {
|
||
|
const separator = uri.indexOf('?') !== -1 ? '&' : '?'
|
||
|
return `${uri}${separator}${key}=${value}`
|
||
|
}
|
||
|
}
|