From b61efcce953fe617dd2e9c5cd2331ce4038faf16 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 22 Apr 2023 12:29:27 +0200 Subject: [PATCH] esm: rename `URLCanParse` to be consistent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/47668 Backport-PR-URL: https://github.com/nodejs/node/pull/50669 Reviewed-By: Michaƫl Zasso Reviewed-By: Jacob Smith Reviewed-By: Matthew Aitken Reviewed-By: Yagiz Nizipli Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- lib/internal/modules/esm/hooks.js | 6 +++--- lib/internal/modules/esm/resolve.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/internal/modules/esm/hooks.js b/lib/internal/modules/esm/hooks.js index 0cf6109f48cd9b..087c262c9208ef 100644 --- a/lib/internal/modules/esm/hooks.js +++ b/lib/internal/modules/esm/hooks.js @@ -33,7 +33,7 @@ const { ERR_WORKER_UNSERIALIZABLE_ERROR, } = require('internal/errors').codes; const { URL } = require('internal/url'); -const { canParse: urlCanParse } = internalBinding('url'); +const { canParse: URLCanParse } = internalBinding('url'); const { receiveMessageOnPort } = require('worker_threads'); const { isAnyArrayBuffer, @@ -272,7 +272,7 @@ class Hooks { // Avoid expensive URL instantiation for known-good URLs if (!this.#validatedUrls.has(url)) { // No need to convert to string, since the type is already validated - if (!urlCanParse(url)) { + if (!URLCanParse(url)) { throw new ERR_INVALID_RETURN_PROPERTY_VALUE( 'a URL string', hookErrIdentifier, @@ -351,7 +351,7 @@ class Hooks { // Avoid expensive URL instantiation for known-good URLs if (!this.#validatedUrls.has(nextUrl)) { // No need to convert to string, since the type is already validated - if (!urlCanParse(nextUrl)) { + if (!URLCanParse(nextUrl)) { throw new ERR_INVALID_ARG_VALUE( `${hookErrIdentifier} url`, nextUrl, diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index ed831db7648506..2b95fdfad13547 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -38,8 +38,8 @@ const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main'); const experimentalNetworkImports = getOptionValue('--experimental-network-imports'); const typeFlag = getOptionValue('--input-type'); -const { URL, pathToFileURL, fileURLToPath, toPathIfFileURL, isURL } = require('internal/url'); -const { canParse: canParseURL } = internalBinding('url'); +const { URL, pathToFileURL, fileURLToPath, isURL, toPathIfFileURL } = require('internal/url'); +const { canParse: URLCanParse } = internalBinding('url'); const { ERR_INPUT_TYPE_NOT_ALLOWED, ERR_INVALID_ARG_TYPE, @@ -395,7 +395,7 @@ function resolvePackageTargetString( if (internal && !StringPrototypeStartsWith(target, '../') && !StringPrototypeStartsWith(target, '/')) { // No need to convert target to string, since it's already presumed to be - if (!canParseURL(target)) { + if (!URLCanParse(target)) { const exportTarget = pattern ? RegExpPrototypeSymbolReplace(patternRegEx, target, () => subpath) : target + subpath;