Skip to content

Commit

Permalink
url: handle unicode hostname if empty
Browse files Browse the repository at this point in the history
PR-URL: nodejs/node#49396
Fixes: nodejs/node#48759
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
sercher committed Apr 25, 2024
1 parent 2bfb541 commit ae94700
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion graal-nodejs/src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void BindingData::Format(const FunctionCallbackInfo<Value>& args) {
out->hash = std::nullopt;
}

if (unicode) {
if (unicode && out->has_hostname()) {
out->host = ada::idna::to_unicode(out->get_hostname());
}

Expand Down
5 changes: 5 additions & 0 deletions graal-nodejs/test/parallel/test-url-format-whatwg.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,8 @@ assert.strictEqual(
url.format(new URL('http://user:pass@xn--0zwm56d.com:8080/path'), { unicode: true }),
'http://user:pass@测试.com:8080/path'
);

assert.strictEqual(
url.format(new URL('tel:123')),
url.format(new URL('tel:123'), { unicode: true })
);

0 comments on commit ae94700

Please sign in to comment.