@@ -17,7 +17,7 @@ const {
1717const experimentalNetworkImports =
1818 getOptionValue ( '--experimental-network-imports' ) ;
1919const { getPackageType, getPackageScopeConfig } = require ( 'internal/modules/esm/resolve' ) ;
20- const { URL , fileURLToPath } = require ( 'internal/url' ) ;
20+ const { fileURLToPath } = require ( 'internal/url' ) ;
2121const { ERR_UNKNOWN_FILE_EXTENSION } = require ( 'internal/errors' ) . codes ;
2222
2323const protocolHandlers = {
@@ -117,27 +117,29 @@ function getHttpProtocolModuleFormat(url, context) {
117117}
118118
119119/**
120- * @param {URL | URL['href'] } url
120+ * @param {URL } url
121121 * @param {{parentURL: string} } context
122122 * @returns {Promise<string> | string | undefined } only works when enabled
123123 */
124124function 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 ) ) {
127127 return null ;
128- return protocolHandlers [ parsed . protocol ] ( parsed , context , true ) ;
128+ }
129+ return protocolHandlers [ protocol ] ( url , context , true ) ;
129130}
130131
131132/**
132- * @param {URL | URL['href'] } url
133+ * @param {URL } url
133134 * @param {{parentURL: string} } context
134135 * @returns {Promise<string> | string | undefined } only works when enabled
135136 */
136137function 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 ) ;
141143}
142144
143145module . exports = {
0 commit comments