| import type { Input, InternalOptions, Options } from '../types/options.js'; | ||
| import { type ResponsePromise } from '../types/ResponsePromise.js'; | ||
| export declare class Ky { | ||
| #private; | ||
| static create(input: Input, options: Options): ResponsePromise; | ||
@@ -5,0 +6,0 @@ request: Request; |
@@ -72,10 +72,10 @@ import { HTTPError } from '../errors/HTTPError.js'; | ||
| } | ||
| const arrayBuffer = await response.clone().arrayBuffer(); | ||
| const responseSize = arrayBuffer.byteLength; | ||
| if (responseSize === 0) { | ||
| const text = await response.text(); | ||
| if (text === '') { | ||
| return ''; | ||
| } | ||
| if (options.parseJson) { | ||
| return options.parseJson(await response.text()); | ||
| return options.parseJson(text); | ||
| } | ||
| return JSON.parse(text); | ||
| } | ||
@@ -87,2 +87,10 @@ return response[type](); | ||
| } | ||
| // eslint-disable-next-line unicorn/prevent-abbreviations | ||
| static #normalizeSearchParams(searchParams) { | ||
| // Filter out undefined values from plain objects | ||
| if (searchParams && typeof searchParams === 'object' && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) { | ||
| return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== undefined)); | ||
| } | ||
| return searchParams; | ||
| } | ||
| request; | ||
@@ -143,3 +151,3 @@ abortController; | ||
| ? this._options.searchParams.replace(/^\?/, '') | ||
| : new URLSearchParams(this._options.searchParams).toString(); | ||
| : new URLSearchParams(Ky.#normalizeSearchParams(this._options.searchParams)).toString(); | ||
| // eslint-disable-next-line unicorn/prevent-abbreviations | ||
@@ -146,0 +154,0 @@ const searchParams = '?' + textSearchParams; |
@@ -5,3 +5,3 @@ import type { LiteralUnion, Required } from './common.js'; | ||
| export type SearchParamsInit = string | string[][] | Record<string, string> | URLSearchParams | undefined; | ||
| export type SearchParamsOption = SearchParamsInit | Record<string, string | number | boolean> | Array<Array<string | number | boolean>>; | ||
| export type SearchParamsOption = SearchParamsInit | Record<string, string | number | boolean | undefined> | Array<Array<string | number | boolean>>; | ||
| export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete'; | ||
@@ -77,2 +77,4 @@ export type Input = string | URL | Request; | ||
| Accepts any value supported by [`URLSearchParams()`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams). | ||
| When passing an object, `undefined` values are automatically filtered out, while `null` values are preserved and converted to the string `'null'`. | ||
| */ | ||
@@ -79,0 +81,0 @@ searchParams?: SearchParamsOption; |
+1
-1
| { | ||
| "name": "ky", | ||
| "version": "1.9.1", | ||
| "version": "1.10.0", | ||
| "description": "Tiny and elegant HTTP client based on the Fetch API", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
+3
-1
@@ -164,3 +164,3 @@ <div align="center"> | ||
| Type: `string | object<string, string | number | boolean> | Array<Array<string | number | boolean>> | URLSearchParams`\ | ||
| Type: `string | object<string, string | number | boolean | undefined> | Array<Array<string | number | boolean>> | URLSearchParams`\ | ||
| Default: `''` | ||
@@ -172,2 +172,4 @@ | ||
| When passing an object, `undefined` values are automatically filtered out, while `null` values are preserved and converted to the string `'null'`. | ||
| ##### prefixUrl | ||
@@ -174,0 +176,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
178529
0.99%1349
0.75%782
0.26%