Node: url: WHATWG API `.origin` behavior does not match the documentation

Created on 2 Sep 2018  路  3Comments  路  Source: nodejs/node

  • Version: v10.9.0, v11.0.0-pre (master)
  • Platform: Linux yoga 4.18.5-arch1-1-ARCH #1 SMP PREEMPT Fri Aug 24 12:48:58 UTC 2018 x86_64 GNU/Linux
  • Subsystem: doc, url

Documented (link):

const myURL = new URL('https://%CF%80.com/foo');
console.log(myURL.href);
// Prints https://xn--1xa.com/foo
console.log(myURL.origin);
// Prints https://蟺.com

Actual behavior:

> const myURL = new URL('https://%CF%80.com/foo');
> console.log(myURL.href);
https://xn--1xa.com/foo
> console.log(myURL.origin);
https://xn--1xa.com

The doc implies that .origin is not punicode-encoded in this scenario, but it in fact is punicode-encoded.

doc whatwg-url

Most helpful comment

@TimothyGu I can include a fix then, I have some minor fixes to url.md planned and this is how I spotted that inconsistency.

All 3 comments

Yeah, this needs a documentation update. We changed the behavior a while ago to reflect a spec change.

@TimothyGu I can include a fix then, I have some minor fixes to url.md planned and this is how I spotted that inconsistency.

23359 should fix it, I believe.

Was this page helpful?
0 / 5 - 0 ratings