Skip to content

Commit 3268f7c

Browse files
committed
feat: allow undefined values in URLSearchParams.ish (treated as '')
1 parent e7a4457 commit 3268f7c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/requestish/src/URLSearchParams.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ import { isJSONPrimitive, isString } from './isRecord.js';
55
export type ish =
66
| URLSearchParams
77
| ConstructorParameters<typeof URLSearchParams>[0]
8-
| Record<string, JSONPrimitive>;
8+
| Record<string, JSONPrimitive | undefined>
9+
| [string, JSONPrimitive | undefined][];
910

1011
export function from(search?: ish): URLSearchParams {
1112
if (search instanceof URLSearchParams) {
1213
return search;
1314
} else if (
14-
isRecord<string, JSONPrimitive>(search, isString, isJSONPrimitive)
15+
search &&
16+
isRecord<string, JSONPrimitive | undefined>(
17+
search,
18+
isString,
19+
isJSONPrimitive
20+
)
1521
) {
1622
return new URLSearchParams(
1723
Object.fromEntries(

0 commit comments

Comments
 (0)