Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: update url constructor example
  • Loading branch information
lirantal committed Apr 20, 2020
commit df1e5b942c3477946bf68b2ff1a17a876816f606
8 changes: 7 additions & 1 deletion doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ WHATWG URL's `origin` property includes `protocol` and `host`, but not
Parsing the URL string using the WHATWG API:

```js
const URL = require('url').URL
const myURL =
new URL('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash');
```
Expand Down Expand Up @@ -106,6 +105,13 @@ const myURL = new URL('/foo', 'https://example.org/');
// https://example.org/foo
```

The URL constructor is accessible as a property on the global object.
It can also be imported from the built-in url module:

```
console.log(URL === require('url').URL); // Prints 'true'.
```

A `TypeError` will be thrown if the `input` or `base` are not valid URLs. Note
that an effort will be made to coerce the given values into strings. For
instance:
Expand Down