@@ -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,
@@ -323,8 +322,9 @@ class ModuleLoader {
323322 getModuleJobForRequire ( specifier , parentURL , importAttributes ) {
324323 assert ( getOptionValue ( '--experimental-require-module' ) ) ;
325324
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 ;
328328 if ( protocol === 'https:' || protocol === 'http:' ) {
329329 throw new ERR_NETWORK_IMPORT_DISALLOWED ( specifier , parentURL ,
330330 'ES modules cannot be loaded by require() from the network' ) ;
0 commit comments