@@ -20,7 +20,7 @@ const experimentalNetworkImports =
20
20
const experimentalSpecifierResolution =
21
21
getOptionValue ( '--experimental-specifier-resolution' ) ;
22
22
const { getPackageType, getPackageScopeConfig } = require ( 'internal/modules/esm/resolve' ) ;
23
- const { URL , fileURLToPath } = require ( 'internal/url' ) ;
23
+ const { fileURLToPath } = require ( 'internal/url' ) ;
24
24
const { ERR_UNKNOWN_FILE_EXTENSION } = require ( 'internal/errors' ) . codes ;
25
25
26
26
const protocolHandlers = {
@@ -99,27 +99,29 @@ function getHttpProtocolModuleFormat(url, context) {
99
99
}
100
100
101
101
/**
102
- * @param {URL | URL['href'] } url
102
+ * @param {URL } url
103
103
* @param {{parentURL: string} } context
104
104
* @returns {Promise<string> | string | undefined } only works when enabled
105
105
*/
106
106
function defaultGetFormatWithoutErrors ( url , context ) {
107
- const parsed = new URL ( url ) ;
108
- if ( ! ObjectPrototypeHasOwnProperty ( protocolHandlers , parsed . protocol ) )
107
+ const protocol = url . protocol ;
108
+ if ( ! ObjectPrototypeHasOwnProperty ( protocolHandlers , protocol ) ) {
109
109
return null ;
110
- return protocolHandlers [ parsed . protocol ] ( parsed , context , true ) ;
110
+ }
111
+ return protocolHandlers [ protocol ] ( url , context , true ) ;
111
112
}
112
113
113
114
/**
114
- * @param {URL | URL['href'] } url
115
+ * @param {URL } url
115
116
* @param {{parentURL: string} } context
116
117
* @returns {Promise<string> | string | undefined } only works when enabled
117
118
*/
118
119
function defaultGetFormat ( url , context ) {
119
- const parsed = new URL ( url ) ;
120
- return ObjectPrototypeHasOwnProperty ( protocolHandlers , parsed . protocol ) ?
121
- protocolHandlers [ parsed . protocol ] ( parsed , context , false ) :
122
- null ;
120
+ const protocol = url . protocol ;
121
+ if ( ! ObjectPrototypeHasOwnProperty ( protocolHandlers , protocol ) ) {
122
+ return null ;
123
+ }
124
+ return protocolHandlers [ protocol ] ( url , context , false ) ;
123
125
}
124
126
125
127
module . exports = {
0 commit comments