Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2022-04-29 17:04:12 +0300
committerMichaƫl Zasso <targos@protonmail.com>2022-05-02 15:39:32 +0300
commita0638a23b099b5ca174680324e856533d765be09 (patch)
tree76ebd6d926a99d7470bf303149568e032e70e0a5 /lib
parent3c796f8328a170e2c2178bbf2e1914c0aa90823b (diff)
esm: fix imports from non-file module
Fixes: https://github.com/nodejs/node/issues/42860 PR-URL: https://github.com/nodejs/node/pull/42881 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Guy Bedford <guybedford@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/modules/esm/resolve.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
index f1298e58dc4..8767109d7c4 100644
--- a/lib/internal/modules/esm/resolve.js
+++ b/lib/internal/modules/esm/resolve.js
@@ -1015,8 +1015,6 @@ function resolveAsCommonJS(specifier, parentURL) {
// TODO(@JakobJingleheimer): de-dupe `specifier` & `parsed`
function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
if (parsedParentURL) {
- const parentURL = fileURLToPath(parsedParentURL?.href);
-
if (
parsedParentURL.protocol === 'http:' ||
parsedParentURL.protocol === 'https:'
@@ -1030,7 +1028,7 @@ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
) {
throw new ERR_NETWORK_IMPORT_DISALLOWED(
specifier,
- parentURL,
+ parsedParentURL,
'remote imports cannot import from a local location.'
);
}
@@ -1041,14 +1039,14 @@ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
NativeModule.canBeRequiredWithoutScheme(specifier)) {
throw new ERR_NETWORK_IMPORT_DISALLOWED(
specifier,
- parentURL,
+ parsedParentURL,
'remote imports cannot import from a local location.'
);
}
throw new ERR_NETWORK_IMPORT_DISALLOWED(
specifier,
- parentURL,
+ parsedParentURL,
'only relative and absolute specifiers are supported.'
);
}