From 528f6b884cac8ff44868595c4085debade5a4a79 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 7 Sep 2020 22:50:56 +0200 Subject: [PATCH] idna: use url module instead of punycode --- doc/api/intl.md | 2 ++ lib/internal/idna.js | 4 ++-- test/parallel/test-bootstrap-modules.js | 2 +- test/parallel/test-url-format.js | 5 ++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/api/intl.md b/doc/api/intl.md index 08571c637e56ea..bbcea771f50a5d 100644 --- a/doc/api/intl.md +++ b/doc/api/intl.md @@ -51,6 +51,7 @@ option: | `String.prototype.toLocale*Case()` | partial (not locale-aware) | full | full | full | | [`Number.prototype.toLocaleString()`][] | partial (not locale-aware) | partial/full (depends on OS) | partial (English-only) | full | | `Date.prototype.toLocale*String()` | partial (not locale-aware) | partial/full (depends on OS) | partial (English-only) | full | +| [Legacy URL Parser][] | partial (no IDN support) | full | full | full | | [WHATWG URL Parser][] | partial (no IDN support) | full | full | full | | [`require('buffer').transcode()`][] | none (function does not exist) | full | full | full | | [REPL][] | partial (inaccurate line editing) | full | full | full | @@ -195,6 +196,7 @@ to be helpful: [ICU]: http://site.icu-project.org/ [REPL]: repl.md#repl_repl [Test262]: https://github.com/tc39/test262/tree/HEAD/test/intl402 +[Legacy URL parser]: url.md#url_legacy_url_api [WHATWG URL parser]: url.md#url_the_whatwg_url_api [`--icu-data-dir`]: cli.md#cli_icu_data_dir_file [`Date.prototype.toLocaleString()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString diff --git a/lib/internal/idna.js b/lib/internal/idna.js index f57f042888f311..8591226d104d3a 100644 --- a/lib/internal/idna.js +++ b/lib/internal/idna.js @@ -4,6 +4,6 @@ if (internalBinding('config').hasIntl) { const { toASCII, toUnicode } = internalBinding('icu'); module.exports = { toASCII, toUnicode }; } else { - const { toASCII, toUnicode } = require('punycode'); - module.exports = { toASCII, toUnicode }; + const { domainToASCII, domainToUnicode } = require('internal/url'); + module.exports = { toASCII: domainToASCII, toUnicode: domainToUnicode }; } diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index 27202dee504880..32ccba5653c3b8 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -151,7 +151,7 @@ if (!common.isMainThread) { if (common.hasIntl) { expectedModules.add('Internal Binding icu'); } else { - expectedModules.add('NativeModule punycode'); + expectedModules.add('NativeModule url'); } if (process.features.inspector) { diff --git a/test/parallel/test-url-format.js b/test/parallel/test-url-format.js index 720a10a97a979b..883d060ac2a152 100644 --- a/test/parallel/test-url-format.js +++ b/test/parallel/test-url-format.js @@ -1,8 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const url = require('url'); +if (!common.hasIntl) + common.skip('missing Intl'); + // Formatting tests to verify that it'll format slightly wonky content to a // valid URL. const formatTests = {