Skip to content

Commit 2a2ed23

Browse files
committed
url: drop ICU requirement for parsing hostnames
1 parent afd49fd commit 2a2ed23

File tree

5 files changed

+19
-68
lines changed

5 files changed

+19
-68
lines changed

deps/ada/ada.gyp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,7 @@
1111
'direct_dependent_settings': {
1212
'include_dirs': ['.'],
1313
},
14-
'sources': [ '<@(ada_sources)' ],
15-
'conditions': [
16-
['v8_enable_i18n_support==0', {
17-
'defines': ['ADA_HAS_ICU=0'],
18-
}],
19-
['v8_enable_i18n_support==1', {
20-
'dependencies': [
21-
'<(icu_gyp_path):icui18n',
22-
'<(icu_gyp_path):icuuc',
23-
],
24-
}],
25-
['OS=="win" and v8_enable_i18n_support==1', {
26-
'dependencies': [
27-
'<(icu_gyp_path):icudata',
28-
],
29-
}],
30-
]
14+
'sources': [ '<@(ada_sources)' ]
3115
},
3216
]
3317
}

doc/api/url.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ return `true`.
129129

130130
#### `new URL(input[, base])`
131131

132+
<!--
133+
changes:
134+
- version: REPLACEME
135+
pr-url: https://github.com/nodejs/node/pull/47339
136+
description: ICU requirement is removed.
137+
-->
138+
132139
* `input` {string} The absolute or relative input URL to parse. If `input`
133140
is relative, then `base` is required. If `input` is absolute, the `base`
134141
is ignored. If `input` is not a string, it is [converted to a string][] first.
@@ -172,9 +179,6 @@ const myURL = new URL('https://測試');
172179
// https://xn--g6w251d/
173180
```
174181

175-
This feature is only available if the `node` executable was compiled with
176-
[ICU][] enabled. If not, the domain names are passed through unchanged.
177-
178182
In cases where it is not known in advance if `input` is an absolute URL
179183
and a `base` is provided, it is advised to validate that the `origin` of
180184
the `URL` object is what is expected.
@@ -1029,6 +1033,10 @@ for (const [name, value] of params) {
10291033
added:
10301034
- v7.4.0
10311035
- v6.13.0
1036+
changes:
1037+
- version: REPLACEME
1038+
pr-url: https://github.com/nodejs/node/pull/47339
1039+
description: ICU requirement is removed.
10321040
-->
10331041

10341042
* `domain` {string}
@@ -1039,9 +1047,6 @@ invalid domain, the empty string is returned.
10391047

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

1042-
This feature is only available if the `node` executable was compiled with
1043-
[ICU][] enabled. If not, the domain names are passed through unchanged.
1044-
10451050
```mjs
10461051
import url from 'node:url';
10471052

@@ -1070,6 +1075,10 @@ console.log(url.domainToASCII('xn--iñvalid.com'));
10701075
added:
10711076
- v7.4.0
10721077
- v6.13.0
1078+
changes:
1079+
- version: REPLACEME
1080+
pr-url: https://github.com/nodejs/node/pull/47339
1081+
description: ICU requirement is removed.
10731082
-->
10741083

10751084
* `domain` {string}
@@ -1080,9 +1089,6 @@ domain, the empty string is returned.
10801089

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

1083-
This feature is only available if the `node` executable was compiled with
1084-
[ICU][] enabled. If not, the domain names are passed through unchanged.
1085-
10861092
```mjs
10871093
import url from 'node:url';
10881094

@@ -1727,7 +1733,6 @@ console.log(myURL.origin);
17271733
// Prints https://xn--1xa.example.com
17281734
```
17291735
1730-
[ICU]: intl.md#options-for-building-nodejs
17311736
[Punycode]: https://tools.ietf.org/html/rfc5891#section-4.4
17321737
[WHATWG URL]: #the-whatwg-url-api
17331738
[WHATWG URL Standard]: https://url.spec.whatwg.org/

lib/internal/idna.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
'use strict';
22

3-
if (internalBinding('config').hasIntl) {
4-
const { toASCII, toUnicode } = internalBinding('icu');
5-
module.exports = { toASCII, toUnicode };
6-
} else {
7-
const { domainToASCII, domainToUnicode } = require('internal/url');
8-
module.exports = { toASCII: domainToASCII, toUnicode: domainToUnicode };
9-
}
3+
const { domainToASCII, domainToUnicode } = require('internal/url');
4+
module.exports = { toASCII: domainToASCII, toUnicode: domainToUnicode };

test/benchmark/test-benchmark-url.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
'use strict';
22

3-
const common = require('../common');
4-
5-
// TODO(@anonrig): Remove this check when Ada removes ICU requirement.
6-
if (!common.hasIntl) {
7-
// A handful of the benchmarks fail when ICU is not included.
8-
// ICU is responsible for ignoring certain inputs from the hostname
9-
// and without it, it is not possible to validate the correctness of the input.
10-
// DomainToASCII method in Unicode specification states which characters are
11-
// ignored and/or remapped. Doing this outside of the scope of DomainToASCII,
12-
// would be a violation of the WHATWG URL specification.
13-
// Please look into: https://unicode.org/reports/tr46/#ProcessingStepMap
14-
common.skip('missing Intl');
15-
}
3+
require('../common');
164

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

test/wpt/status/url.json

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
{
2-
"toascii.window.js": {
3-
"requires": ["small-icu"]
4-
},
52
"percent-encoding.window.js": {
6-
"requires": ["small-icu"],
73
"skip": "TODO: port from .window.js"
84
},
95
"historical.any.js": {
10-
"requires": ["small-icu"],
116
"fail": {
127
"note": "We are faking location with a URL object for the sake of the testharness and it has searchParams.",
138
"expected": [
@@ -17,26 +12,10 @@
1712
]
1813
}
1914
},
20-
"urlencoded-parser.any.js": {
21-
"requires": ["small-icu"]
22-
},
23-
"url-constructor.any.js": {
24-
"requires": ["small-icu"]
25-
},
26-
"url-origin.any.js": {
27-
"requires": ["small-icu"]
28-
},
29-
"url-setters.any.js": {
30-
"requires": ["small-icu"]
31-
},
3215
"url-setters-a-area.window.js": {
3316
"skip": "already tested in url-setters.any.js"
3417
},
35-
"IdnaTestV2.window.js": {
36-
"requires": ["small-icu"]
37-
},
3818
"javascript-urls.window.js": {
39-
"required": ["small-icu"],
4019
"skip": "requires document.body reference"
4120
}
4221
}

0 commit comments

Comments
 (0)