- From: Dmitry <notifications@github.com>
- Date: Mon, 05 Dec 2022 01:53:31 -0800
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 5 December 2022 09:53:44 UTC
```ts
const FAKE_HOST = 'https://fake-host';
export default function urlAddParams(url: string, urlParams: object = {}): string {
let urlObj: URL;
try {
urlObj = new URL(url);
} catch {
/** FIXME remove hack when https://github.com/whatwg/url/issues/531 is ready */
urlObj = new URL(url, FAKE_HOST);
}
Object.entries(urlParams).forEach(([paramName, paramValue]) =>
urlObj.searchParams.append(paramName, paramValue)
);
return `${urlObj}`.replace(FAKE_HOST, '');
}
```
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/531#issuecomment-1337050285
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/url/issues/531/1337050285@github.com>
Received on Monday, 5 December 2022 09:53:44 UTC