Skip to content

Commit fb909e9

Browse files
committed
Tweaks
1 parent 6be69a5 commit fb909e9

File tree

3 files changed

+12
-209
lines changed

3 files changed

+12
-209
lines changed

source/core/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import timer, {type ClientRequestWithTimings, type Timings, type IncomingMessage
2020
import getBodySize from './utils/get-body-size.js';
2121
import proxyEvents from './utils/proxy-events.js';
2222
import timedOut, {TimeoutError as TimedOutTimeoutError} from './timed-out.js';
23-
import urlToOptions from './utils/url-to-options.js';
2423
import stripUrlAuth from './utils/strip-url-auth.js';
2524
import WeakableMap from './utils/weakable-map.js';
2625
import 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

source/core/utils/url-to-options.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

test/url-to-options.ts

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)