@@ -20,7 +20,6 @@ import timer, {type ClientRequestWithTimings, type Timings, type IncomingMessage
2020import getBodySize from './utils/get-body-size.js' ;
2121import proxyEvents from './utils/proxy-events.js' ;
2222import timedOut , { TimeoutError as TimedOutTimeoutError } from './timed-out.js' ;
23- import urlToOptions from './utils/url-to-options.js' ;
2423import stripUrlAuth from './utils/strip-url-auth.js' ;
2524import WeakableMap from './utils/weakable-map.js' ;
2625import calculateRetryDelay from './calculate-retry-delay.js' ;
@@ -1699,8 +1698,18 @@ export default class Request extends Duplex implements RequestEvents<Request> {
16991698
17001699 private async _createCacheableRequest ( url : URL , options : RequestOptions ) : Promise < ClientRequest | ResponseLike > {
17011700 return new Promise < ClientRequest | ResponseLike > ( ( resolve , reject ) => {
1702- // TODO: Remove `utils/url-to-options.ts` when `cacheable-request` is fixed
1703- Object . assign ( options , urlToOptions ( url ) ) ;
1701+ Object . assign ( options , {
1702+ protocol : url . protocol ,
1703+ hostname : is . string ( url . hostname ) && url . hostname . startsWith ( '[' ) ? url . hostname . slice ( 1 , - 1 ) : url . hostname ,
1704+ host : url . host ,
1705+ hash : url . hash === '' ? '' : ( url . hash ?? null ) ,
1706+ search : url . search === '' ? '' : ( url . search ?? null ) ,
1707+ pathname : url . pathname ,
1708+ href : url . href ,
1709+ path : `${ url . pathname || '' } ${ url . search || '' } ` ,
1710+ ...( is . string ( url . port ) && url . port . length > 0 ? { port : Number ( url . port ) } : { } ) ,
1711+ ...( url . username || url . password ? { auth : `${ url . username || '' } :${ url . password || '' } ` } : { } ) ,
1712+ } ) ;
17041713
17051714 let request : ClientRequest | Promise < ClientRequest > ;
17061715
0 commit comments