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