Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

ky

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ky - npm Package Compare versions

Comparing version
1.9.1
to
1.10.0
+1
-0
distribution/core/Ky.d.ts
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;

+13
-5

@@ -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;

{
"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",

@@ -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