Skip to content

Commit

Permalink
url: expose WHATWG url.origin as ASCII
Browse files Browse the repository at this point in the history
PR-URL: #13126
Refs: whatwg/url#297
Refs: web-platform-tests/wpt#5944
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
TimothyGu committed May 25, 2017
1 parent 6caf1b0 commit 413691f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 3 additions & 6 deletions lib/internal/url.js
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions 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 =
Expand Down Expand Up @@ -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": "",
Expand All @@ -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": "",
Expand All @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand All @@ -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": "",
Expand Down

0 comments on commit 413691f

Please sign in to comment.