From 413691fde0de0b8820d16dbaa4a27de6b62f54b5 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Sat, 20 May 2017 00:52:52 -0700 Subject: [PATCH] url: expose WHATWG url.origin as ASCII PR-URL: https://github.com/nodejs/node/pull/13126 Refs: https://github.com/whatwg/url/issues/297 Refs: https://github.com/w3c/web-platform-tests/pull/5944 Reviewed-By: Refael Ackermann Reviewed-By: James M Snell Reviewed-By: Daijiro Wachi Reviewed-By: Joyee Cheung --- lib/internal/url.js | 9 +++------ test/fixtures/url-tests.js | 11 ++++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index 2ff397c6b6ec1b..bb33f75b090109 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -65,12 +65,9 @@ function toUSVString(val) { // Refs: https://html.spec.whatwg.org/multipage/browsers.html#concept-origin-opaque const kOpaqueOrigin = 'null'; -// Refs: -// - https://html.spec.whatwg.org/multipage/browsers.html#unicode-serialisation-of-an-origin -// - https://html.spec.whatwg.org/multipage/browsers.html#ascii-serialisation-of-an-origin -function serializeTupleOrigin(scheme, host, port, unicode = true) { - const unicodeHost = unicode ? domainToUnicode(host) : host; - return `${scheme}//${unicodeHost}${port === null ? '' : `:${port}`}`; +// Refs: https://html.spec.whatwg.org/multipage/browsers.html#ascii-serialisation-of-an-origin +function serializeTupleOrigin(scheme, host, port) { + return `${scheme}//${host}${port === null ? '' : `:${port}`}`; } // This class provides the internal state of a URL object. An instance of this diff --git a/test/fixtures/url-tests.js b/test/fixtures/url-tests.js index f75ea129906002..00643f961321df 100644 --- a/test/fixtures/url-tests.js +++ b/test/fixtures/url-tests.js @@ -1,7 +1,7 @@ 'use strict'; /* WPT Refs: - https://github.com/w3c/web-platform-tests/blob/0f26c418a5/url/urltestdata.json + https://github.com/w3c/web-platform-tests/blob/8df7c9c215/url/urltestdata.json License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html */ module.exports = @@ -3679,7 +3679,7 @@ module.exports = "input": "http://你好你好", "base": "http://other.com/", "href": "http://xn--6qqa088eba/", - "origin": "http://你好你好", + "origin": "http://xn--6qqa088eba", "protocol": "http:", "username": "", "password": "", @@ -3694,7 +3694,7 @@ module.exports = "input": "https://faß.ExAmPlE/", "base": "about:blank", "href": "https://xn--fa-hia.example/", - "origin": "https://faß.example", + "origin": "https://xn--fa-hia.example", "protocol": "https:", "username": "", "password": "", @@ -3709,6 +3709,7 @@ module.exports = "input": "sc://faß.ExAmPlE/", "base": "about:blank", "href": "sc://fa%C3%9F.ExAmPlE/", + "origin": "null", "protocol": "sc:", "username": "", "password": "", @@ -4617,7 +4618,7 @@ module.exports = "input": "ftp://%e2%98%83", "base": "about:blank", "href": "ftp://xn--n3h/", - "origin": "ftp://☃", + "origin": "ftp://xn--n3h", "protocol": "ftp:", "username": "", "password": "", @@ -4632,7 +4633,7 @@ module.exports = "input": "https://%e2%98%83", "base": "about:blank", "href": "https://xn--n3h/", - "origin": "https://☃", + "origin": "https://xn--n3h", "protocol": "https:", "username": "", "password": "",