Skip to content

Commit

Permalink
recognize bigint as stringifiable
Browse files Browse the repository at this point in the history
  • Loading branch information
bug-brain committed Jan 30, 2024
1 parent c5c2efc commit 4902988
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export type StringifyOptions = {
readonly skipEmptyString?: boolean;
};

export type Stringifiable = string | boolean | number | null | undefined; // eslint-disable-line @typescript-eslint/ban-types
export type Stringifiable = string | boolean | number | bigint | null | undefined; // eslint-disable-line @typescript-eslint/ban-types

export type StringifiableRecord = Record<
string,
Expand Down
7 changes: 7 additions & 0 deletions test/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ test('different types', t => {
t.is(queryString.stringify(0), '');
});

test('primitive types', t => {
t.is(queryString.stringify({ a: "string" }), "a=string")
t.is(queryString.stringify({ a: true, b: false }), "a=true&b=false")
t.is(queryString.stringify({ a: 0, b: 1n }), "a=0&b=1")
t.is(queryString.stringify({a: null, b: undefined}), "a")
})

test('URI encode', t => {
t.is(queryString.stringify({'foo bar': 'baz faz'}), 'foo%20bar=baz%20faz');
t.is(queryString.stringify({'foo bar': 'baz\'faz'}), 'foo%20bar=baz%27faz');
Expand Down

0 comments on commit 4902988

Please sign in to comment.