mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
20 lines
392 B
TypeScript
20 lines
392 B
TypeScript
import qs from 'qs';
|
|
import url from 'parse-url';
|
|
|
|
interface IRouterLocation {
|
|
pathname: string;
|
|
search: string;
|
|
}
|
|
|
|
export const addQueryToLocation = (
|
|
{ pathname = '', search = '' }: Record<string, unknown> & IRouterLocation,
|
|
key = '',
|
|
value = '',
|
|
) => {
|
|
const { query } = url(pathname + search);
|
|
return `${pathname}?${qs.stringify({
|
|
...query,
|
|
[key]: value,
|
|
})}`;
|
|
};
|