Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: various small revisions in url #14478

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
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
26 changes: 17 additions & 9 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ const myURL =
added: v7.0.0
-->

*Note*: Using the `delete` keyword on `URL` objects (e.g.
`delete myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will
still return `true`.

### Class: URL

Browser-compatible `URL` class, implemented by following the WHATWG URL
Standard. [Examples of parsed URLs][] may be found in the Standard itself.

*Note*: In accordance with browser conventions, all properties of `URL` objects
are implemented as getters and setters on the class prototype, rather than as
data properties on the object itself. Thus, unlike [legacy urlObject][]s, using
the `delete` keyword on any properties of `URL` objects (e.g. `delete
myURL.protocol`, `delete myURL.pathname`, etc) has no effect but will still
return `true`.

#### Constructor: new URL(input[, base])

* `input` {string} The input URL to parse
Expand Down Expand Up @@ -116,7 +123,8 @@ const myURL = new URL('https://你好你好');
// https://xn--6qqa088eba/
```

Additional [examples of parsed URLs][] may be found in the WHATWG URL Standard.
*Note*: This feature is only available if the `node` executable was compiled
with [ICU][] enabled. If not, the domain names are passed through unchanged.

#### url.hash

Expand Down Expand Up @@ -211,9 +219,7 @@ will be thrown.

* {string}

Gets the read-only serialization of the URL's origin. Unicode characters that
may be contained within the hostname will be encoded as-is without [Punycode][]
encoding.
Gets the read-only serialization of the URL's origin.

```js
const { URL } = require('url');
Expand All @@ -226,7 +232,7 @@ console.log(myURL.origin);
const { URL } = require('url');
const idnURL = new URL('https://你好你好');
console.log(idnURL.origin);
// Prints https://你好你好
// Prints https://xn--6qqa088eba

console.log(idnURL.hostname);
// Prints xn--6qqa088eba
Expand Down Expand Up @@ -1150,3 +1156,5 @@ console.log(myURL.origin);
[examples of parsed URLs]: https://url.spec.whatwg.org/#example-url-parsing
[percent-encoded]: #whatwg-percent-encoding
[stable sorting algorithm]: https://en.wikipedia.org/wiki/Sorting_algorithm#Stability
[ICU]: intl.html#intl_options_for_building_node_js
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this and the next line are out of ASCII sorting order used for bottom references.

[legacy urlObject]: #url_legacy_urlobject