From 9a5340b1bf688168822ce1556331b6c60603d537 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Fri, 23 Jun 2017 08:51:44 +0800 Subject: [PATCH 1/2] doc: update url.origin IDNA behavior Fixes: 413691fde0 "url: expose WHATWG url.origin as ASCII" Refs: https://github.com/nodejs/node/pull/13126 --- doc/api/url.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/api/url.md b/doc/api/url.md index bdb04a23dd5c98..a4fe496ba072f5 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -211,9 +211,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'); @@ -226,7 +224,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 From 4eb3dca14c62c03abea3ca8fffdbb97f83b892c0 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Mon, 26 Jun 2017 11:59:20 +0800 Subject: [PATCH 2/2] doc: various small revisions in url --- doc/api/url.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/doc/api/url.md b/doc/api/url.md index a4fe496ba072f5..cee57a146b4ebf 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -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 @@ -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 @@ -1148,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 +[legacy urlObject]: #url_legacy_urlobject