@@ -28,14 +28,13 @@ const {
2828 ERR_UNKNOWN_MODULE_FORMAT ,
2929} = require ( 'internal/errors' ) . codes ;
3030const { getOptionValue } = require ( 'internal/options' ) ;
31- const { isURL, pathToFileURL, URL } = require ( 'internal/url' ) ;
31+ const { isURL, pathToFileURL, URLParse } = require ( 'internal/url' ) ;
3232const { emitExperimentalWarning, kEmptyObject } = require ( 'internal/util' ) ;
3333const {
3434 compileSourceTextModule,
3535 getDefaultConditions,
3636} = require ( 'internal/modules/esm/utils' ) ;
3737const { kImplicitAssertType } = require ( 'internal/modules/esm/assert' ) ;
38- const { canParse } = internalBinding ( 'url' ) ;
3938const { ModuleWrap, kEvaluating, kEvaluated } = internalBinding ( 'module_wrap' ) ;
4039const {
4140 urlToFilename,
@@ -321,8 +320,9 @@ class ModuleLoader {
321320 getModuleJobForRequire ( specifier , parentURL , importAttributes ) {
322321 assert ( getOptionValue ( '--experimental-require-module' ) ) ;
323322
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 ;
326326 if ( protocol === 'https:' || protocol === 'http:' ) {
327327 throw new ERR_NETWORK_IMPORT_DISALLOWED ( specifier , parentURL ,
328328 'ES modules cannot be loaded by require() from the network' ) ;
0 commit comments