Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#69277 Add allowEmptyArray option to qs.str…
Browse files Browse the repository at this point in the history
…ingify by @ianswain-himarley
  • Loading branch information
ianswain-himarley authored Apr 16, 2024
1 parent 0c50781 commit 9c5aeea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions types/qs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare namespace QueryString {
addQueryPrefix?: boolean | undefined;
charset?: "utf-8" | "iso-8859-1" | undefined;
charsetSentinel?: boolean | undefined;
allowEmptyArrays?: boolean | undefined;
}

type IStringifyDynamicOptions<AllowDots extends BooleanOptional> = AllowDots extends true
Expand Down
5 changes: 5 additions & 0 deletions types/qs/qs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ qs.parse("a=b&c=d", { delimiter: "&" });
assert.deepEqual(withEmptyArrays, { foo: [], bar: "baz" });
});

(() => {
var withEmptyArrays = qs.stringify({ foo: [], bar: "baz" }, { allowEmptyArrays: true });
assert.deepEqual(withEmptyArrays, "foo[]&bar=baz");
});

(() => {
var withDots = qs.parse("name%252Eobj.first=John&name%252Eobj.last=Doe", { decodeDotInKeys: true });
assert.deepEqual(withDots, { "name.obj": { first: "John", last: "Doe" } });
Expand Down

0 comments on commit 9c5aeea

Please sign in to comment.