[whatwg/url] Make combining a URL (string) with a query easier (#413)

In particular if you have a URL, either as a string (inc. a relative URL) or an object, and some kind of structure that could be passed to `URLSearchParams`'s constructor, it should be easier to get a new URL out of that (either a string or object).

What you can currently do is something like (substitution):
```js
const url = new URL(input, location);
url.query = new URLSearchParams(params);
```
or (additive):
```js
const url = new URL(input, location);
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
```
Both are quite verbose. Perhaps something like
```
URL.withQuery(input, params)
```
though note you'd lose the base argument (we'd grab that from the global) and flexibility on substitution or additive (gotta pick).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/413

Received on Thursday, 23 August 2018 13:47:13 UTC