# URL

> How Elide supports the URL and URLSearchParams globals per the URL Standard, including `URL.parse()`, `URL.canParse()` and the live `searchParams` object.

`URL` is a global and follows the [URL Standard](https://url.spec.whatwg.org/), including `URL.parse()` and
`URL.canParse()`.

## Example

```js
// weburl.mjs
const url = new URL("../docs?page=2#intro", "https://elide.dev/guide/start");
console.log(url.href);
console.log(url.pathname, url.searchParams.get("page"), url.hash);

url.searchParams.append("tag", "node");
url.searchParams.sort();
console.log(url.search);
console.log(URL.canParse("not a url"), URL.parse("http://[::1]:8080/")?.host);
```

`elide run weburl.mjs` prints:

```text
https://elide.dev/docs?page=2#intro
/docs 2 #intro
?page=2&tag=node
false [::1]:8080
```

## URLSearchParams

`URLSearchParams` is a global and follows the same standard. `url.searchParams` returns the same live object on every
access.

<!-- api-reference:start 0f26d93f1e27 -->
## Reference

**Status:** Full · 8,682 of 9,046 suite tests pass (96.0%) · since 1.1.0

### Exports

| Export | Kind | Status | Notes |
| --- | --- | --- | --- |
| `URL` | class | Full | `URL.parse()`, `URL.canParse()`, `href`, `origin`, `protocol`, `username`, `password`, `host`, `hostname`, `port`, `pathname`, `search`, `searchParams`, `hash`, `toJSON()` |
| `URLSearchParams` | class | Full | `size`, `append()`, `delete()`, `get()`, `getAll()`, `has()`, `set()`, `sort()`, `iteration` |

**Tests:** [wpt-wintertc `url`](https://github.com/elide-dev/testsuite/blob/main/reports/1.6.0%2B6e718933f/4cbcae6c33a8/wpt-wintertc/wpt-wintertc.md): 8,682 pass, 364 fail, 0 error, 2,251 skipped. Failing: `url/toascii.window.js` (298), `url/IdnaTestV2.any.js` (30), `url/url-constructor.any.js` (12), `url/url-setters.any.js` (12), `url/urlsearchparams-constructor.any.js` (6), `url/urlencoded-parser.any.js` (2), `url/idlharness.any.js`, `url/url-origin.any.js`, and 2 more.
<!-- api-reference:end -->
