diff options
author | Yichao 'Peak' Ji <peakji@users.noreply.github.com> | 2018-05-03 15:13:25 +0800 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-05-07 10:32:22 +0200 |
commit | 2a96ee284cc5aecec9b66d24bddb06acbcc72c98 (patch) | |
tree | de8ae5c8fa999f26274a715ce11f7b8507c434aa /test/parallel/test-url-format-whatwg.js | |
parent | 8f6ab9f799925da836b6c106ed9a8b3d95a2935f (diff) | |
download | android-node-v8-2a96ee284cc5aecec9b66d24bddb06acbcc72c98.tar.gz android-node-v8-2a96ee284cc5aecec9b66d24bddb06acbcc72c98.tar.bz2 android-node-v8-2a96ee284cc5aecec9b66d24bddb06acbcc72c98.zip |
url: fix WHATWG host formatting error
The current url.format implementation will return an invalid URL string
without the host if there is a port and unicode: true.
This unexpected behavior is caused by domainToUnicode, which expects
a hostname instead of a host string according to node_url.cc.
Adds both a fix and a test for the issue.
PR-URL: https://github.com/nodejs/node/pull/20493
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Diffstat (limited to 'test/parallel/test-url-format-whatwg.js')
-rw-r--r-- | test/parallel/test-url-format-whatwg.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/parallel/test-url-format-whatwg.js b/test/parallel/test-url-format-whatwg.js index 26cef6063c..e5c3e369e8 100644 --- a/test/parallel/test-url-format-whatwg.js +++ b/test/parallel/test-url-format-whatwg.js @@ -111,3 +111,8 @@ assert.strictEqual( url.format(myURL, { unicode: 0 }), 'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c' ); + +assert.strictEqual( + url.format(new URL('http://xn--0zwm56d.com:8080/path'), { unicode: true }), + 'http://测试.com:8080/path' +); |