@@ -33,7 +33,7 @@ const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main');
3333const experimentalNetworkImports =
3434 getOptionValue ( '--experimental-network-imports' ) ;
3535const inputTypeFlag = getOptionValue ( '--input-type' ) ;
36- const { URL , pathToFileURL, fileURLToPath, isURL } = require ( 'internal/url' ) ;
36+ const { URL , pathToFileURL, fileURLToPath, isURL, URLParse } = require ( 'internal/url' ) ;
3737const { getCWDURL, setOwnProperty } = require ( 'internal/util' ) ;
3838const { canParse : URLCanParse } = internalBinding ( 'url' ) ;
3939const { legacyMainResolve : FSLegacyMainResolve } = internalBinding ( 'fs' ) ;
@@ -1054,21 +1054,17 @@ function defaultResolve(specifier, context = {}) {
10541054
10551055 let parsedParentURL ;
10561056 if ( parentURL ) {
1057- try {
1058- parsedParentURL = new URL ( parentURL ) ;
1059- } catch {
1060- // Ignore exception
1061- }
1057+ parsedParentURL = URLParse ( parentURL ) ;
10621058 }
10631059
10641060 let parsed , protocol ;
1065- try {
1066- if ( shouldBeTreatedAsRelativeOrAbsolutePath ( specifier ) ) {
1067- parsed = new URL ( specifier , parsedParentURL ) ;
1068- } else {
1069- parsed = new URL ( specifier ) ;
1070- }
1061+ if ( shouldBeTreatedAsRelativeOrAbsolutePath ( specifier ) ) {
1062+ parsed = URLParse ( specifier , parsedParentURL ) ;
1063+ } else {
1064+ parsed = URLParse ( specifier ) ;
1065+ }
10711066
1067+ if ( parsed != null ) {
10721068 // Avoid accessing the `protocol` property due to the lazy getters.
10731069 protocol = parsed . protocol ;
10741070 if ( protocol === 'data:' ||
@@ -1081,8 +1077,6 @@ function defaultResolve(specifier, context = {}) {
10811077 ) {
10821078 return { __proto__ : null , url : parsed . href } ;
10831079 }
1084- } catch {
1085- // Ignore exception
10861080 }
10871081
10881082 // There are multiple deep branches that can either throw or return; instead
0 commit comments