Skip to content

Commit

Permalink
url: handle unicode hostname if empty
Browse files Browse the repository at this point in the history
PR-URL: #49396
Fixes: #48759
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
anonrig authored and UlisesGascon committed Sep 10, 2023
1 parent 6ed47bd commit e787673
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,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 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 e787673

Please sign in to comment.