@@ -33,7 +33,7 @@ const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main');
33
33
const experimentalNetworkImports =
34
34
getOptionValue ( '--experimental-network-imports' ) ;
35
35
const inputTypeFlag = getOptionValue ( '--input-type' ) ;
36
- const { URL , pathToFileURL, fileURLToPath, isURL } = require ( 'internal/url' ) ;
36
+ const { URL , pathToFileURL, fileURLToPath, isURL, URLParse } = require ( 'internal/url' ) ;
37
37
const { getCWDURL, setOwnProperty } = require ( 'internal/util' ) ;
38
38
const { canParse : URLCanParse } = internalBinding ( 'url' ) ;
39
39
const { legacyMainResolve : FSLegacyMainResolve } = internalBinding ( 'fs' ) ;
@@ -1054,20 +1054,17 @@ function defaultResolve(specifier, context = {}) {
1054
1054
1055
1055
let parsedParentURL ;
1056
1056
if ( parentURL ) {
1057
- try {
1058
- parsedParentURL = new URL ( parentURL ) ;
1059
- } catch {
1060
- // Ignore exception
1061
- }
1057
+ parsedParentURL = URLParse ( parentURL ) ;
1062
1058
}
1063
1059
1064
1060
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
+ }
1066
+
1067
+ if ( parsed != null ) {
1071
1068
// Avoid accessing the `protocol` property due to the lazy getters.
1072
1069
protocol = parsed . protocol ;
1073
1070
@@ -1090,11 +1087,6 @@ function defaultResolve(specifier, context = {}) {
1090
1087
) {
1091
1088
return { __proto__ : null , url : parsed . href } ;
1092
1089
}
1093
- } catch ( e ) {
1094
- if ( e ?. code === 'ERR_NETWORK_IMPORT_DISALLOWED' ) {
1095
- throw e ;
1096
- }
1097
- // Ignore exception
1098
1090
}
1099
1091
1100
1092
// There are multiple deep branches that can either throw or return; instead
0 commit comments