Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v18.x] Revert "url: drop ICU requirement for parsing hostnames" #48869

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@ added:
- v7.4.0
- v6.13.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/48869
description: ICU requirement is back.
- version: v18.17.0
pr-url: https://github.com/nodejs/node/pull/47339
description: ICU requirement is removed.
Expand All @@ -1047,6 +1050,9 @@ invalid domain, the empty string is returned.

It performs the inverse operation to [`url.domainToUnicode()`][].

This feature is only available if the `node` executable was compiled with
[ICU][] enabled. If not, the domain names are passed through unchanged.

```mjs
import url from 'node:url';

Expand Down Expand Up @@ -1076,6 +1082,9 @@ added:
- v7.4.0
- v6.13.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/48869
description: ICU requirement is back.
- version: v18.17.0
pr-url: https://github.com/nodejs/node/pull/47339
description: ICU requirement is removed.
Expand All @@ -1089,6 +1098,9 @@ domain, the empty string is returned.

It performs the inverse operation to [`url.domainToASCII()`][].

This feature is only available if the `node` executable was compiled with
[ICU][] enabled. If not, the domain names are passed through unchanged.

```mjs
import url from 'node:url';

Expand Down Expand Up @@ -1731,6 +1743,7 @@ console.log(myURL.origin);
// Prints https://xn--1xa.example.com
```

[ICU]: intl.md#options-for-building-nodejs
[Punycode]: https://tools.ietf.org/html/rfc5891#section-4.4
[WHATWG URL]: #the-whatwg-url-api
[WHATWG URL Standard]: https://url.spec.whatwg.org/
Expand Down
9 changes: 7 additions & 2 deletions lib/internal/idna.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
'use strict';

const { domainToASCII, domainToUnicode } = require('internal/url');
module.exports = { toASCII: domainToASCII, toUnicode: domainToUnicode };
if (internalBinding('config').hasIntl) {
const { toASCII, toUnicode } = internalBinding('icu');
module.exports = { toASCII, toUnicode };
} else {
const { domainToASCII, domainToUnicode } = require('internal/url');
module.exports = { toASCII: domainToASCII, toUnicode: domainToUnicode };
}
14 changes: 13 additions & 1 deletion test/benchmark/test-benchmark-url.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
'use strict';

require('../common');
const common = require('../common');

// TODO(@anonrig): Remove this check when Ada removes ICU requirement.
if (!common.hasIntl) {
// A handful of the benchmarks fail when ICU is not included.
// ICU is responsible for ignoring certain inputs from the hostname
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file shouldn’t be reverted as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be, url.parse depends on ICU if this PR lands.

// and without it, it is not possible to validate the correctness of the input.
// DomainToASCII method in Unicode specification states which characters are
// ignored and/or remapped. Doing this outside of the scope of DomainToASCII,
// would be a violation of the WHATWG URL specification.
// Please look into: https://unicode.org/reports/tr46/#ProcessingStepMap
common.skip('missing Intl');
}

const runBenchmark = require('../common/benchmark');

Expand Down