@@ -17,7 +17,7 @@ const {
17
17
const experimentalNetworkImports =
18
18
getOptionValue ( '--experimental-network-imports' ) ;
19
19
const { getPackageType, getPackageScopeConfig } = require ( 'internal/modules/esm/resolve' ) ;
20
- const { URL , fileURLToPath } = require ( 'internal/url' ) ;
20
+ const { fileURLToPath } = require ( 'internal/url' ) ;
21
21
const { ERR_UNKNOWN_FILE_EXTENSION } = require ( 'internal/errors' ) . codes ;
22
22
23
23
const protocolHandlers = {
@@ -117,27 +117,29 @@ function getHttpProtocolModuleFormat(url, context) {
117
117
}
118
118
119
119
/**
120
- * @param {URL | URL['href'] } url
120
+ * @param {URL } url
121
121
* @param {{parentURL: string} } context
122
122
* @returns {Promise<string> | string | undefined } only works when enabled
123
123
*/
124
124
function defaultGetFormatWithoutErrors ( url , context ) {
125
- const parsed = new URL ( url ) ;
126
- if ( ! ObjectPrototypeHasOwnProperty ( protocolHandlers , parsed . protocol ) )
125
+ const protocol = url . protocol ;
126
+ if ( ! ObjectPrototypeHasOwnProperty ( protocolHandlers , protocol ) ) {
127
127
return null ;
128
- return protocolHandlers [ parsed . protocol ] ( parsed , context , true ) ;
128
+ }
129
+ return protocolHandlers [ protocol ] ( url , context , true ) ;
129
130
}
130
131
131
132
/**
132
- * @param {URL | URL['href'] } url
133
+ * @param {URL } url
133
134
* @param {{parentURL: string} } context
134
135
* @returns {Promise<string> | string | undefined } only works when enabled
135
136
*/
136
137
function defaultGetFormat ( url , context ) {
137
- const parsed = new URL ( url ) ;
138
- return ObjectPrototypeHasOwnProperty ( protocolHandlers , parsed . protocol ) ?
139
- protocolHandlers [ parsed . protocol ] ( parsed , context , false ) :
140
- null ;
138
+ const protocol = url . protocol ;
139
+ if ( ! ObjectPrototypeHasOwnProperty ( protocolHandlers , protocol ) ) {
140
+ return null ;
141
+ }
142
+ return protocolHandlers [ protocol ] ( url , context , false ) ;
141
143
}
142
144
143
145
module . exports = {
0 commit comments