summaryrefslogtreecommitdiff
path: root/test/parallel/test-url-format-whatwg.js
diff options
context:
space:
mode:
authorYichao 'Peak' Ji <peakji@users.noreply.github.com>2018-05-03 15:13:25 +0800
committerAnatoli Papirovski <apapirovski@mac.com>2018-05-07 10:32:22 +0200
commit2a96ee284cc5aecec9b66d24bddb06acbcc72c98 (patch)
treede8ae5c8fa999f26274a715ce11f7b8507c434aa /test/parallel/test-url-format-whatwg.js
parent8f6ab9f799925da836b6c106ed9a8b3d95a2935f (diff)
downloadandroid-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.js5
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'
+);