@@ -29,14 +29,13 @@ const {
2929 ERR_UNKNOWN_MODULE_FORMAT ,
3030} = require ( 'internal/errors' ) . codes ;
3131const { getOptionValue } = require ( 'internal/options' ) ;
32- const { isURL, pathToFileURL, URL } = require ( 'internal/url' ) ;
32+ const { isURL, pathToFileURL, URLParse } = require ( 'internal/url' ) ;
3333const { emitExperimentalWarning, kEmptyObject } = require ( 'internal/util' ) ;
3434const {
3535 compileSourceTextModule,
3636 getDefaultConditions,
3737} = require ( 'internal/modules/esm/utils' ) ;
3838const { kImplicitTypeAttribute } = require ( 'internal/modules/esm/assert' ) ;
39- const { canParse } = internalBinding ( 'url' ) ;
4039const { ModuleWrap, kEvaluating, kEvaluated } = internalBinding ( 'module_wrap' ) ;
4140const {
4241 urlToFilename,
@@ -322,8 +321,9 @@ class ModuleLoader {
322321 getModuleJobForRequire ( specifier , parentURL , importAttributes ) {
323322 assert ( getOptionValue ( '--experimental-require-module' ) ) ;
324323
325- if ( canParse ( specifier ) ) {
326- const protocol = new URL ( specifier ) . protocol ;
324+ const parsed = URLParse ( specifier ) ;
325+ if ( parsed != null ) {
326+ const protocol = parsed . protocol ;
327327 if ( protocol === 'https:' || protocol === 'http:' ) {
328328 throw new ERR_NETWORK_IMPORT_DISALLOWED ( specifier , parentURL ,
329329 'ES modules cannot be loaded by require() from the network' ) ;
0 commit comments