From cf3c0f368d20f208e422adc4a09e9650485bf815 Mon Sep 17 00:00:00 2001 From: Salim Rutaganda <155084668+rutaganda-salim@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:24:25 +0200 Subject: [PATCH 1/3] Updated resolve.js --- lib/internal/modules/esm/resolve.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index 2aa5a3df4a93bd..a23294f06a122d 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -1068,15 +1068,11 @@ function defaultResolve(specifier, context = {}) { // Avoid accessing the `protocol` property due to the lazy getters. protocol = parsed.protocol; - if (protocol === 'data:' && - parsedParentURL.protocol !== 'file:' && - experimentalNetworkImports) { - throw new ERR_NETWORK_IMPORT_DISALLOWED( - specifier, - parsedParentURL, - 'import data: from a non file: is not allowed', - ); - } + if (protocol === 'data:' && parentProtocol !== 'file:' && parentProtocol !== 'data:') { + throw new ERR_NETWORK_IMPORT_DISALLOWED( + 'import of \'data:\' is not supported: import data: from a non file: is not allowed' + ); +} if (protocol === 'data:' || (experimentalNetworkImports && ( From 57aad40dea50ed30280a31d882d8d39f33116326 Mon Sep 17 00:00:00 2001 From: Salim Rutaganda <155084668+rutaganda-salim@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:25:27 +0200 Subject: [PATCH 2/3] Update resolve.js From 5222d9173a244fa2404273a8f58c053dd8ac4315 Mon Sep 17 00:00:00 2001 From: Salim Rutaganda <155084668+rutaganda-salim@users.noreply.github.com> Date: Tue, 23 Jul 2024 15:27:27 +0200 Subject: [PATCH 3/3] Update lib/internal/modules/esm/resolve.js Co-authored-by: James M Snell --- lib/internal/modules/esm/resolve.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index a23294f06a122d..c0b09e51d8cc8f 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -1069,8 +1069,8 @@ function defaultResolve(specifier, context = {}) { protocol = parsed.protocol; if (protocol === 'data:' && parentProtocol !== 'file:' && parentProtocol !== 'data:') { - throw new ERR_NETWORK_IMPORT_DISALLOWED( - 'import of \'data:\' is not supported: import data: from a non file: is not allowed' + throw new ERR_NETWORK_IMPORT_DISALLOWED( + 'import of \'data:\' is not supported: import data: from a non file: is not allowed' ); } if (protocol === 'data:' ||