got 14.6.6 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/source/as-promise/index.d.ts +2 -2
  2. package/dist/source/as-promise/index.js +59 -41
  3. package/dist/source/as-promise/types.d.ts +10 -23
  4. package/dist/source/as-promise/types.js +1 -17
  5. package/dist/source/core/calculate-retry-delay.js +1 -4
  6. package/dist/source/core/diagnostics-channel.js +12 -21
  7. package/dist/source/core/errors.d.ts +2 -1
  8. package/dist/source/core/errors.js +7 -10
  9. package/dist/source/core/index.d.ts +19 -7
  10. package/dist/source/core/index.js +725 -307
  11. package/dist/source/core/options.d.ts +92 -91
  12. package/dist/source/core/options.js +616 -303
  13. package/dist/source/core/response.d.ts +5 -3
  14. package/dist/source/core/response.js +26 -3
  15. package/dist/source/core/timed-out.d.ts +1 -1
  16. package/dist/source/core/timed-out.js +3 -3
  17. package/dist/source/core/utils/defer-to-connect.js +5 -17
  18. package/dist/source/core/utils/get-body-size.d.ts +1 -1
  19. package/dist/source/core/utils/get-body-size.js +3 -20
  20. package/dist/source/core/utils/proxy-events.d.ts +1 -1
  21. package/dist/source/core/utils/proxy-events.js +3 -3
  22. package/dist/source/core/utils/strip-url-auth.d.ts +1 -0
  23. package/dist/source/core/utils/strip-url-auth.js +9 -0
  24. package/dist/source/core/utils/timer.js +5 -7
  25. package/dist/source/core/utils/unhandle.js +1 -2
  26. package/dist/source/create.js +83 -27
  27. package/dist/source/index.d.ts +2 -3
  28. package/dist/source/index.js +0 -4
  29. package/dist/source/types.d.ts +40 -70
  30. package/package.json +34 -38
  31. package/readme.md +2 -2
  32. package/dist/source/core/utils/is-form-data.d.ts +0 -7
  33. package/dist/source/core/utils/is-form-data.js +0 -4
  34. package/dist/source/core/utils/url-to-options.d.ts +0 -14
  35. package/dist/source/core/utils/url-to-options.js +0 -22
@@ -1,6 +1,5 @@
1
- import type { Buffer } from 'node:buffer';
2
1
  import type { Spread } from 'type-fest';
3
- import type { CancelableRequest } from './as-promise/types.js';
2
+ import type { RequestPromise } from './as-promise/types.js';
4
3
  import type { Response } from './core/response.js';
5
4
  import type Options from './core/options.js';
6
5
  import { type PaginationOptions, type OptionsInit } from './core/options.js';
@@ -18,7 +17,7 @@ export type InstanceDefaults = {
18
17
  /**
19
18
  An array of functions. You execute them directly by calling `got()`.
20
19
  They are some sort of "global hooks" - these functions are called first.
21
- The last handler (*it's hidden*) is either `asPromise` or `asStream`, depending on the `options.isStream` property.
20
+ The last handler (*it's hidden*) is either `asPromise` or `asStream`, depending on whether `got()` or `got.stream()` was called.
22
21
 
23
22
  @default []
24
23
  */
@@ -34,7 +33,7 @@ export type InstanceDefaults = {
34
33
  /**
35
34
  A Request object returned by calling Got, or any of the Got HTTP alias request functions.
36
35
  */
37
- export type GotReturn = Request | CancelableRequest;
36
+ export type GotReturn = Request | RequestPromise;
38
37
  /**
39
38
  A function to handle options and returns a Request object.
40
39
  It acts sort of like a "global hook", and will be called before any actual request is made.
@@ -47,7 +46,7 @@ export type ExtendOptions = {
47
46
  /**
48
47
  An array of functions. You execute them directly by calling `got()`.
49
48
  They are some sort of "global hooks" - these functions are called first.
50
- The last handler (*it's hidden*) is either `asPromise` or `asStream`, depending on the `options.isStream` property.
49
+ The last handler (*it's hidden*) is either `asPromise` or `asStream`, depending on whether `got()` or `got.stream()` was called.
51
50
 
52
51
  @default []
53
52
  */
@@ -59,12 +58,11 @@ export type ExtendOptions = {
59
58
  @default false
60
59
  */
61
60
  mutableDefaults?: boolean;
62
- } & OptionsInit;
63
- export type StrictOptions = Except<OptionsInit, 'isStream' | 'responseType' | 'resolveBodyOnly'>;
64
- export type StreamOptions = Merge<OptionsInit, {
65
- isStream?: true;
66
- }>;
67
- export type OptionsWithPagination<T = unknown, R = unknown> = Merge<OptionsInit, {
61
+ } & Except<OptionsInit, 'url'>;
62
+ type OptionsInitWithoutUrl = Except<OptionsInit, 'url'>;
63
+ export type StrictOptions = Except<OptionsInitWithoutUrl, 'responseType' | 'resolveBodyOnly'>;
64
+ export type StreamOptions = OptionsInitWithoutUrl;
65
+ export type OptionsWithPagination<T = unknown, R = unknown> = Merge<OptionsInitWithoutUrl, {
68
66
  pagination?: PaginationOptions<T, R>;
69
67
  }>;
70
68
  /**
@@ -124,107 +122,81 @@ export type GotPaginate = {
124
122
  all: (<T, R = unknown>(url: string | URL, options?: OptionsWithPagination<T, R>) => Promise<T[]>) & (<T, R = unknown>(options?: OptionsWithPagination<T, R>) => Promise<T[]>);
125
123
  };
126
124
  export type OptionsOfTextResponseBody = Merge<StrictOptions, {
127
- isStream?: false;
128
125
  responseType?: 'text';
129
126
  }>;
130
127
  export type OptionsOfTextResponseBodyOnly = Merge<StrictOptions, {
131
- isStream?: false;
132
128
  resolveBodyOnly: true;
133
129
  responseType?: 'text';
134
130
  }>;
135
131
  export type OptionsOfTextResponseBodyWrapped = Merge<StrictOptions, {
136
- isStream?: false;
137
132
  resolveBodyOnly: false;
138
133
  responseType?: 'text';
139
134
  }>;
140
135
  export type OptionsOfJSONResponseBody = Merge<StrictOptions, {
141
- isStream?: false;
142
136
  responseType?: 'json';
143
137
  }>;
144
138
  export type OptionsOfJSONResponseBodyOnly = Merge<StrictOptions, {
145
- isStream?: false;
146
139
  resolveBodyOnly: true;
147
140
  responseType?: 'json';
148
141
  }>;
149
142
  export type OptionsOfJSONResponseBodyWrapped = Merge<StrictOptions, {
150
- isStream?: false;
151
143
  resolveBodyOnly: false;
152
144
  responseType?: 'json';
153
145
  }>;
154
146
  export type OptionsOfBufferResponseBody = Merge<StrictOptions, {
155
- isStream?: false;
156
147
  responseType?: 'buffer';
157
148
  }>;
158
149
  export type OptionsOfBufferResponseBodyOnly = Merge<StrictOptions, {
159
- isStream?: false;
160
150
  resolveBodyOnly: true;
161
151
  responseType?: 'buffer';
162
152
  }>;
163
153
  export type OptionsOfBufferResponseBodyWrapped = Merge<StrictOptions, {
164
- isStream?: false;
165
154
  resolveBodyOnly: false;
166
155
  responseType?: 'buffer';
167
156
  }>;
168
- export type OptionsOfUnknownResponseBody = Merge<StrictOptions, {
169
- isStream?: false;
170
- }>;
157
+ export type OptionsOfUnknownResponseBody = StrictOptions;
171
158
  export type OptionsOfUnknownResponseBodyOnly = Merge<StrictOptions, {
172
- isStream?: false;
173
159
  resolveBodyOnly: true;
174
160
  }>;
175
161
  export type OptionsOfUnknownResponseBodyWrapped = Merge<StrictOptions, {
176
- isStream?: false;
177
162
  resolveBodyOnly: false;
178
163
  }>;
179
- type DefaultResponseBodyType<U extends ExtendOptions> = U['responseType'] extends 'json' ? unknown : U['responseType'] extends 'buffer' ? Buffer : string;
164
+ type DefaultResponseBodyType<U extends ExtendOptions> = U['responseType'] extends 'json' ? unknown : U['responseType'] extends 'buffer' ? Uint8Array<ArrayBuffer> : string;
165
+ type GotResponseResult<U extends ExtendOptions, BodyType> = U['resolveBodyOnly'] extends true ? RequestPromise<BodyType> : RequestPromise<Response<BodyType>>;
180
166
  export type GotRequestFunction<U extends ExtendOptions = Record<string, unknown>> = {
181
- (url: string | URL): U['resolveBodyOnly'] extends true ? CancelableRequest<DefaultResponseBodyType<U>> : CancelableRequest<Response<DefaultResponseBodyType<U>>>;
182
- (url: string | URL, options?: OptionsOfTextResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<string> : CancelableRequest<Response<string>>;
183
- <T>(url: string | URL, options?: OptionsOfJSONResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<T> : CancelableRequest<Response<T>>;
184
- (url: string | URL, options?: OptionsOfBufferResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<Buffer> : CancelableRequest<Response<Buffer>>;
185
- (url: string | URL, options?: OptionsOfUnknownResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest : CancelableRequest<Response>;
186
- (url: string | URL, options?: OptionsOfTextResponseBodyWrapped): CancelableRequest<Response<string>>;
187
- <T>(url: string | URL, options?: OptionsOfJSONResponseBodyWrapped): CancelableRequest<Response<T>>;
188
- (url: string | URL, options?: OptionsOfBufferResponseBodyWrapped): CancelableRequest<Response<Buffer>>;
189
- (url: string | URL, options?: OptionsOfUnknownResponseBodyWrapped): CancelableRequest<Response>;
190
- (url: string | URL, options?: OptionsOfTextResponseBodyOnly): CancelableRequest<string>;
191
- <T>(url: string | URL, options?: OptionsOfJSONResponseBodyOnly): CancelableRequest<T>;
192
- (url: string | URL, options?: OptionsOfBufferResponseBodyOnly): CancelableRequest<Buffer>;
193
- (url: string | URL, options?: OptionsOfUnknownResponseBodyOnly): CancelableRequest;
194
- (options: {
195
- url: string | URL;
196
- }): U['resolveBodyOnly'] extends true ? CancelableRequest<DefaultResponseBodyType<U>> : CancelableRequest<Response<DefaultResponseBodyType<U>>>;
197
- (options: OptionsOfTextResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<string> : CancelableRequest<Response<string>>;
198
- <T>(options: OptionsOfJSONResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<T> : CancelableRequest<Response<T>>;
199
- (options: OptionsOfBufferResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<Buffer> : CancelableRequest<Response<Buffer>>;
200
- (options: OptionsOfUnknownResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest : CancelableRequest<Response>;
201
- (options: OptionsOfTextResponseBodyWrapped): CancelableRequest<Response<string>>;
202
- <T>(options: OptionsOfJSONResponseBodyWrapped): CancelableRequest<Response<T>>;
203
- (options: OptionsOfBufferResponseBodyWrapped): CancelableRequest<Response<Buffer>>;
204
- (options: OptionsOfUnknownResponseBodyWrapped): CancelableRequest<Response>;
205
- (options: OptionsOfTextResponseBodyOnly): CancelableRequest<string>;
206
- <T>(options: OptionsOfJSONResponseBodyOnly): CancelableRequest<T>;
207
- (options: OptionsOfBufferResponseBodyOnly): CancelableRequest<Buffer>;
208
- (options: OptionsOfUnknownResponseBodyOnly): CancelableRequest;
209
- (url: string | URL, options?: Merge<OptionsInit, {
210
- isStream: true;
211
- }>): Request;
212
- (options: Merge<OptionsInit, {
213
- isStream: true;
214
- }>): Request;
215
- (url: string | URL, options?: OptionsInit): CancelableRequest | Request;
216
- (options: OptionsInit): CancelableRequest | Request;
217
- (url: undefined, options: undefined, defaults: Options): CancelableRequest | Request;
167
+ (url: string | URL, options?: OptionsOfUnknownResponseBody): GotResponseResult<U, DefaultResponseBodyType<U>>;
168
+ (url: string | URL, options?: OptionsOfUnknownResponseBodyWrapped): RequestPromise<Response<DefaultResponseBodyType<U>>>;
169
+ (url: string | URL, options?: OptionsOfUnknownResponseBodyOnly): RequestPromise<DefaultResponseBodyType<U>>;
170
+ (url: string | URL, options?: OptionsOfTextResponseBody): GotResponseResult<U, string>;
171
+ <T>(url: string | URL, options?: OptionsOfJSONResponseBody): GotResponseResult<U, T>;
172
+ (url: string | URL, options?: OptionsOfBufferResponseBody): GotResponseResult<U, Uint8Array<ArrayBuffer>>;
173
+ (url: string | URL, options?: OptionsOfTextResponseBodyWrapped): RequestPromise<Response<string>>;
174
+ <T>(url: string | URL, options?: OptionsOfJSONResponseBodyWrapped): RequestPromise<Response<T>>;
175
+ (url: string | URL, options?: OptionsOfBufferResponseBodyWrapped): RequestPromise<Response<Uint8Array<ArrayBuffer>>>;
176
+ (url: string | URL, options?: OptionsOfTextResponseBodyOnly): RequestPromise<string>;
177
+ <T>(url: string | URL, options?: OptionsOfJSONResponseBodyOnly): RequestPromise<T>;
178
+ (url: string | URL, options?: OptionsOfBufferResponseBodyOnly): RequestPromise<Uint8Array<ArrayBuffer>>;
179
+ (options: OptionsOfUnknownResponseBody): GotResponseResult<U, DefaultResponseBodyType<U>>;
180
+ (options: OptionsOfUnknownResponseBodyWrapped): RequestPromise<Response<DefaultResponseBodyType<U>>>;
181
+ (options: OptionsOfUnknownResponseBodyOnly): RequestPromise<DefaultResponseBodyType<U>>;
182
+ (options: OptionsOfTextResponseBody): GotResponseResult<U, string>;
183
+ <T>(options: OptionsOfJSONResponseBody): GotResponseResult<U, T>;
184
+ (options: OptionsOfBufferResponseBody): GotResponseResult<U, Uint8Array<ArrayBuffer>>;
185
+ (options: OptionsOfTextResponseBodyWrapped): RequestPromise<Response<string>>;
186
+ <T>(options: OptionsOfJSONResponseBodyWrapped): RequestPromise<Response<T>>;
187
+ (options: OptionsOfBufferResponseBodyWrapped): RequestPromise<Response<Uint8Array<ArrayBuffer>>>;
188
+ (options: OptionsOfTextResponseBodyOnly): RequestPromise<string>;
189
+ <T>(options: OptionsOfJSONResponseBodyOnly): RequestPromise<T>;
190
+ (options: OptionsOfBufferResponseBodyOnly): RequestPromise<Uint8Array<ArrayBuffer>>;
191
+ (url: string | URL, options?: OptionsInitWithoutUrl): RequestPromise | Request;
192
+ (options: OptionsInitWithoutUrl): RequestPromise | Request;
193
+ (url: undefined, options: undefined, defaults: Options): RequestPromise | Request;
218
194
  };
219
195
  /**
220
196
  All available HTTP request methods provided by Got.
221
197
  */
222
198
  export type HTTPAlias = 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete';
223
- type GotStreamFunction = ((url?: string | URL, options?: Merge<OptionsInit, {
224
- isStream?: true;
225
- }>) => Request) & ((options?: Merge<OptionsInit, {
226
- isStream?: true;
227
- }>) => Request);
199
+ type GotStreamFunction = ((url?: string | URL, options?: StreamOptions) => Request) & ((options?: StreamOptions) => Request);
228
200
  /**
229
201
  An instance of `got.stream()`.
230
202
  */
@@ -234,8 +206,6 @@ An instance of `got`.
234
206
  */
235
207
  export type Got<GotOptions extends ExtendOptions = ExtendOptions> = {
236
208
  /**
237
- Sets `options.isStream` to `true`.
238
-
239
209
  Returns a [duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with additional events:
240
210
  - request
241
211
  - response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "got",
3
- "version": "14.6.6",
3
+ "version": "15.0.0",
4
4
  "description": "Human-friendly and powerful HTTP request library for Node.js",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/got",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "sideEffects": false,
14
14
  "engines": {
15
- "node": ">=20"
15
+ "node": ">=22"
16
16
  },
17
17
  "scripts": {
18
18
  "test": "xo && tsc --noEmit && NODE_OPTIONS='--import=tsx/esm' ava",
@@ -51,64 +51,60 @@
51
51
  "ky"
52
52
  ],
53
53
  "dependencies": {
54
- "@sindresorhus/is": "^7.0.1",
54
+ "@sindresorhus/is": "^7.2.0",
55
55
  "byte-counter": "^0.1.0",
56
56
  "cacheable-lookup": "^7.0.0",
57
- "cacheable-request": "^13.0.12",
57
+ "cacheable-request": "^13.0.18",
58
+ "chunk-data": "^0.1.0",
58
59
  "decompress-response": "^10.0.0",
59
- "form-data-encoder": "^4.0.2",
60
60
  "http2-wrapper": "^2.2.1",
61
- "keyv": "^5.5.3",
62
- "lowercase-keys": "^3.0.0",
63
- "p-cancelable": "^4.0.1",
61
+ "keyv": "^5.6.0",
62
+ "lowercase-keys": "^4.0.1",
64
63
  "responselike": "^4.0.2",
65
- "type-fest": "^4.26.1"
64
+ "type-fest": "^5.4.4",
65
+ "uint8array-extras": "^1.5.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@hapi/bourne": "^3.0.0",
69
- "@sindresorhus/tsconfig": "^6.0.0",
70
- "@sinonjs/fake-timers": "^11.2.2",
69
+ "@sindresorhus/tsconfig": "^8.1.0",
70
+ "@sinonjs/fake-timers": "^15.1.0",
71
71
  "@types/benchmark": "^2.1.5",
72
- "@types/express": "^5.0.0",
73
- "@types/node": "^22.7.5",
72
+ "@types/express": "^5.0.6",
73
+ "@types/node": "^25.3.0",
74
74
  "@types/pem": "^1.14.4",
75
- "@types/readable-stream": "^4.0.14",
76
- "@types/request": "^2.48.12",
77
- "@types/sinon": "^17.0.2",
78
- "@types/sinonjs__fake-timers": "^8.1.5",
79
- "ava": "^5.3.1",
80
- "axios": "^1.7.7",
75
+ "@types/readable-stream": "^4.0.23",
76
+ "@types/request": "^2.48.13",
77
+ "@types/sinon": "^21.0.0",
78
+ "@types/sinonjs__fake-timers": "^15.0.1",
79
+ "ava": "^6.4.1",
80
+ "axios": "^1.13.5",
81
81
  "benchmark": "^2.1.4",
82
82
  "bluebird": "^3.7.2",
83
- "body-parser": "^1.20.3",
83
+ "body-parser": "^2.2.2",
84
84
  "c8": "^10.1.3",
85
- "chunk-data": "^0.1.0",
86
85
  "create-cert": "^1.0.6",
87
86
  "create-test-server": "^3.0.1",
88
- "del-cli": "^6.0.0",
89
- "delay": "^6.0.0",
90
- "expect-type": "^1.0.0",
91
- "express": "^4.21.1",
92
- "form-data": "^4.0.0",
93
- "formdata-node": "^6.0.3",
87
+ "del-cli": "^7.0.0",
88
+ "delay": "^7.0.0",
89
+ "expect-type": "^1.3.0",
90
+ "express": "^5.2.1",
94
91
  "get-stream": "^9.0.1",
95
- "nock": "^13.5.5",
96
92
  "node-fetch": "^3.3.2",
97
- "np": "^10.0.5",
98
- "p-event": "^6.0.1",
93
+ "np": "^11.0.2",
94
+ "p-event": "^7.1.0",
99
95
  "pem": "^1.14.8",
100
96
  "pify": "^6.1.0",
101
- "quick-lru": "^7.2.0",
102
- "readable-stream": "^4.4.2",
97
+ "quick-lru": "^7.3.0",
98
+ "readable-stream": "^4.7.0",
103
99
  "request": "^2.88.2",
104
- "sinon": "^19.0.2",
100
+ "sinon": "^21.0.1",
105
101
  "slow-stream": "0.0.4",
106
- "tempy": "^3.1.0",
102
+ "tempy": "^3.2.0",
107
103
  "then-busboy": "^5.2.1",
108
- "tough-cookie": "^4.1.4",
109
- "tsx": "^4.19.1",
110
- "typescript": "^5.6.3",
111
- "xo": "^0.56.0"
104
+ "tough-cookie": "^6.0.0",
105
+ "tsx": "^4.21.0",
106
+ "typescript": "^5.9.3",
107
+ "xo": "^1.2.3"
112
108
  },
113
109
  "ava": {
114
110
  "files": [
package/readme.md CHANGED
@@ -176,7 +176,7 @@ By default, Got will retry on failure. To disable this option, set [`options.ret
176
176
  | Promise API | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
177
177
  | Stream API | :heavy_check_mark: | Node.js only | :x: | :x: | :heavy_check_mark: |
178
178
  | Pagination API | :heavy_check_mark: | :x: | :x: | :x: | :x: |
179
- | Request cancelation | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
179
+ | Request aborting | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
180
180
  | RFC compliant caching | :heavy_check_mark: | :x: | :x: | :x: | :x: |
181
181
  | Cookies (out-of-the-box) | :heavy_check_mark: | :x: | :x: | :x: | :x: |
182
182
  | Follows redirects | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
@@ -359,7 +359,7 @@ By default, Got will retry on failure. To disable this option, set [`options.ret
359
359
 
360
360
  [Click here][InstallSizeOfTheDependencies] to see the install size of the Got dependencies.
361
361
 
362
- [InstallSizeOfTheDependencies]: https://packagephobia.com/result?p=@sindresorhus/is@7.0.0,@szmarczak/http-timer@5.0.1,cacheable-lookup@7.0.0,cacheable-request@12.0.1,decompress-response@6.0.0,form-data-encoder@4.0.2,http2-wrapper@2.2.1,lowercase-keys@3.0.0,p-cancelable@4.0.1,responselike@3.0.0,type-fest@4.19.0
362
+ [InstallSizeOfTheDependencies]: https://packagephobia.com/result?p=@sindresorhus/is@7.2.0,byte-counter@0.1.0,cacheable-lookup@7.0.0,cacheable-request@13.0.18,chunk-data@0.1.0,decompress-response@10.0.0,http2-wrapper@2.2.1,keyv@5.6.0,lowercase-keys@4.0.1,responselike@4.0.2,type-fest@5.4.4
363
363
 
364
364
  ## Maintainers
365
365
 
@@ -1,7 +0,0 @@
1
- import type { Readable } from 'node:stream';
2
- type FormData = {
3
- getBoundary: () => string;
4
- getLength: (callback: (error: Error | null, length: number) => void) => void;
5
- } & Readable;
6
- export default function isFormData(body: unknown): body is FormData;
7
- export {};
@@ -1,4 +0,0 @@
1
- import is from '@sindresorhus/is';
2
- export default function isFormData(body) {
3
- return is.nodeStream(body) && is.function(body.getBoundary);
4
- }
@@ -1,14 +0,0 @@
1
- import type { UrlWithStringQuery } from 'node:url';
2
- export type LegacyUrlOptions = {
3
- protocol: string;
4
- hostname: string;
5
- host: string;
6
- hash: string | null;
7
- search: string | null;
8
- pathname: string;
9
- href: string;
10
- path: string;
11
- port?: number;
12
- auth?: string;
13
- };
14
- export default function urlToOptions(url: URL | UrlWithStringQuery): LegacyUrlOptions;
@@ -1,22 +0,0 @@
1
- import is from '@sindresorhus/is';
2
- export default function urlToOptions(url) {
3
- // Cast to URL
4
- url = url;
5
- const options = {
6
- protocol: url.protocol,
7
- hostname: is.string(url.hostname) && url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname,
8
- host: url.host,
9
- hash: url.hash,
10
- search: url.search,
11
- pathname: url.pathname,
12
- href: url.href,
13
- path: `${url.pathname || ''}${url.search || ''}`,
14
- };
15
- if (is.string(url.port) && url.port.length > 0) {
16
- options.port = Number(url.port);
17
- }
18
- if (url.username || url.password) {
19
- options.auth = `${url.username || ''}:${url.password || ''}`;
20
- }
21
- return options;
22
- }