| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a6bceae commit c6f4a6f
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1050,8 +1050,6 @@ function resolveAsCommonJS(specifier, parentURL) { | |||
| 1050 | 1050 | // TODO(@JakobJingleheimer): de-dupe `specifier` & `parsed` | |
| 1051 | 1051 | function checkIfDisallowedImport(specifier, parsed, parsedParentURL) { | |
| 1052 | 1052 | if (parsedParentURL) { | |
| 1053 | - const parentURL = fileURLToPath(parsedParentURL?.href); | ||
| 1054 | - | ||
| 1055 | 1053 | if ( | |
| 1056 | 1054 | parsedParentURL.protocol === 'http:' || | |
| 1057 | 1055 | parsedParentURL.protocol === 'https:' | |
@@ -1065,7 +1063,7 @@ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) { | |||
| 1065 | 1063 | ) { | |
| 1066 | 1064 | throw new ERR_NETWORK_IMPORT_DISALLOWED( | |
| 1067 | 1065 | specifier, | |
| 1068 | - parentURL, | ||
| 1066 | + parsedParentURL, | ||
| 1069 | 1067 | 'remote imports cannot import from a local location.' | |
| 1070 | 1068 | ); | |
| 1071 | 1069 | } | |
@@ -1075,14 +1073,14 @@ function checkIfDisallowedImport(specifier, parsed, parsedParentURL) { | |||
| 1075 | 1073 | if (NativeModule.canBeRequiredByUsers(specifier)) { | |
| 1076 | 1074 | throw new ERR_NETWORK_IMPORT_DISALLOWED( | |
| 1077 | 1075 | specifier, | |
| 1078 | - parentURL, | ||
| 1076 | + parsedParentURL, | ||
| 1079 | 1077 | 'remote imports cannot import from a local location.' | |
| 1080 | 1078 | ); | |
| 1081 | 1079 | } | |
| 1082 | 1080 | ||
| 1083 | 1081 | throw new ERR_NETWORK_IMPORT_DISALLOWED( | |
| 1084 | 1082 | specifier, | |
| 1085 | - parentURL, | ||
| 1083 | + parsedParentURL, | ||
| 1086 | 1084 | 'only relative and absolute specifiers are supported.' | |
| 1087 | 1085 | ); | |
| 1088 | 1086 | } | |
| 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 | |
|---|---|---|---|
@@ -162,7 +162,7 @@ for (const { protocol, createServer } of [ | |||
| 162 | 162 | export default 1;`); | |
| 163 | 163 | await assert.rejects( | |
| 164 | 164 | import(fileDep.href), | |
| 165 | - { code: 'ERR_INVALID_URL_SCHEME' } | ||
| 165 | + { code: 'ERR_NETWORK_IMPORT_DISALLOWED' } | ||
| 166 | 166 | ); | |
| 167 | 167 | ||
| 168 | 168 | const builtinDep = new URL(url.href); | |
@@ -172,7 +172,7 @@ for (const { protocol, createServer } of [ | |||
| 172 | 172 | `); | |
| 173 | 173 | await assert.rejects( | |
| 174 | 174 | import(builtinDep.href), | |
| 175 | - { code: 'ERR_INVALID_URL_SCHEME' } | ||
| 175 | + { code: 'ERR_NETWORK_IMPORT_DISALLOWED' } | ||
| 176 | 176 | ); | |
| 177 | 177 | ||
| 178 | 178 | const unprefixedBuiltinDep = new URL(url.href); | |
@@ -182,7 +182,7 @@ for (const { protocol, createServer } of [ | |||
| 182 | 182 | `); | |
| 183 | 183 | await assert.rejects( | |
| 184 | 184 | import(unprefixedBuiltinDep.href), | |
| 185 | - { code: 'ERR_INVALID_URL_SCHEME' } | ||
| 185 | + { code: 'ERR_NETWORK_IMPORT_DISALLOWED' } | ||
| 186 | 186 | ); | |
| 187 | 187 | ||
| 188 | 188 | const unsupportedMIME = new URL(url.href); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments