| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3c796f8 commit a0638a2
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1015,8 +1015,6 @@ function resolveAsCommonJS(specifier, parentURL) { | |||
| 1015 | 1015 | // TODO(@JakobJingleheimer): de-dupe `specifier` & `parsed` | |
| 1016 | 1016 | function checkIfDisallowedImport(specifier, parsed, parsedParentURL) { | |
| 1017 | 1017 | if (parsedParentURL) { | |
| 1018 | - const parentURL = fileURLToPath(parsedParentURL?.href); | ||
| 1019 | - | ||
| 1020 | 1018 | if ( | |
| 1021 | 1019 | parsedParentURL.protocol === 'http:' || | |
| 1022 | 1020 | parsedParentURL.protocol === 'https:' | |
@@ -1030,7 +1028,7 @@ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) { | |||
| 1030 | 1028 | ) { | |
| 1031 | 1029 | throw new ERR_NETWORK_IMPORT_DISALLOWED( | |
| 1032 | 1030 | specifier, | |
| 1033 | - parentURL, | ||
| 1031 | + parsedParentURL, | ||
| 1034 | 1032 | 'remote imports cannot import from a local location.' | |
| 1035 | 1033 | ); | |
| 1036 | 1034 | } | |
@@ -1041,14 +1039,14 @@ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) { | |||
| 1041 | 1039 | NativeModule.canBeRequiredWithoutScheme(specifier)) { | |
| 1042 | 1040 | throw new ERR_NETWORK_IMPORT_DISALLOWED( | |
| 1043 | 1041 | specifier, | |
| 1044 | - parentURL, | ||
| 1042 | + parsedParentURL, | ||
| 1045 | 1043 | 'remote imports cannot import from a local location.' | |
| 1046 | 1044 | ); | |
| 1047 | 1045 | } | |
| 1048 | 1046 | ||
| 1049 | 1047 | throw new ERR_NETWORK_IMPORT_DISALLOWED( | |
| 1050 | 1048 | specifier, | |
| 1051 | - parentURL, | ||
| 1049 | + parsedParentURL, | ||
| 1052 | 1050 | 'only relative and absolute specifiers are supported.' | |
| 1053 | 1051 | ); | |
| 1054 | 1052 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | + const fixtures = require('../common/fixtures'); | ||
| 3 | 4 | const assert = require('assert'); | |
| 4 | 5 | function createURL(mime, body) { | |
| 5 | 6 | return `data:${mime},${body}`; | |
@@ -107,4 +108,8 @@ function createBase64URL(mime, body) { | |||
| 107 | 108 | const module = await import(plainESMURL); | |
| 108 | 109 | assert.strictEqual(module.default, 2); | |
| 109 | 110 | } | |
| 111 | + { | ||
| 112 | + const plainESMURL = `data:text/javascript,${encodeURIComponent(`import ${JSON.stringify(fixtures.fileURL('es-module-url', 'empty.js'))}`)}`; | ||
| 113 | + await import(plainESMURL); | ||
| 114 | + } | ||
| 110 | 115 | })().then(common.mustCall()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,7 +167,7 @@ for (const { protocol, createServer } of [ | |||
| 167 | 167 | export default 1;`); | |
| 168 | 168 | await assert.rejects( | |
| 169 | 169 | import(fileDep.href), | |
| 170 | - { code: 'ERR_INVALID_URL_SCHEME' } | ||
| 170 | + { code: 'ERR_NETWORK_IMPORT_DISALLOWED' } | ||
| 171 | 171 | ); | |
| 172 | 172 | ||
| 173 | 173 | const builtinDep = new URL(url.href); | |
@@ -177,7 +177,7 @@ for (const { protocol, createServer } of [ | |||
| 177 | 177 | `); | |
| 178 | 178 | await assert.rejects( | |
| 179 | 179 | import(builtinDep.href), | |
| 180 | - { code: 'ERR_INVALID_URL_SCHEME' } | ||
| 180 | + { code: 'ERR_NETWORK_IMPORT_DISALLOWED' } | ||
| 181 | 181 | ); | |
| 182 | 182 | ||
| 183 | 183 | const unprefixedBuiltinDep = new URL(url.href); | |
@@ -187,7 +187,7 @@ for (const { protocol, createServer } of [ | |||
| 187 | 187 | `); | |
| 188 | 188 | await assert.rejects( | |
| 189 | 189 | import(unprefixedBuiltinDep.href), | |
| 190 | - { code: 'ERR_INVALID_URL_SCHEME' } | ||
| 190 | + { code: 'ERR_NETWORK_IMPORT_DISALLOWED' } | ||
| 191 | 191 | ); | |
| 192 | 192 | ||
| 193 | 193 | const unsupportedMIME = new URL(url.href); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments