@@ -28,14 +28,13 @@ const {
|
28 | 28 | ERR_UNKNOWN_MODULE_FORMAT, |
29 | 29 | } = require('internal/errors').codes; |
30 | 30 | const { getOptionValue } = require('internal/options'); |
31 | | -const { isURL, pathToFileURL, URL } = require('internal/url'); |
| 31 | +const { isURL, pathToFileURL, URLParse } = require('internal/url'); |
32 | 32 | const { emitExperimentalWarning, kEmptyObject } = require('internal/util'); |
33 | 33 | const { |
34 | 34 | compileSourceTextModule, |
35 | 35 | getDefaultConditions, |
36 | 36 | } = require('internal/modules/esm/utils'); |
37 | 37 | const { kImplicitAssertType } = require('internal/modules/esm/assert'); |
38 | | -const { canParse } = internalBinding('url'); |
39 | 38 | const { ModuleWrap, kEvaluating, kEvaluated } = internalBinding('module_wrap'); |
40 | 39 | const { |
41 | 40 | urlToFilename, |
@@ -321,8 +320,9 @@ class ModuleLoader {
|
321 | 320 | getModuleJobForRequire(specifier, parentURL, importAttributes) { |
322 | 321 | assert(getOptionValue('--experimental-require-module')); |
323 | 322 | |
324 | | -if (canParse(specifier)) { |
325 | | -const protocol = new URL(specifier).protocol; |
| 323 | +const parsed = URLParse(specifier); |
| 324 | +if (parsed != null) { |
| 325 | +const protocol = parsed.protocol; |
326 | 326 | if (protocol === 'https:' || protocol === 'http:') { |
327 | 327 | throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parentURL, |
328 | 328 | 'ES modules cannot be loaded by require() from the network'); |
|