Skip to content

Commit

Permalink
fix(encodeQueryItem): stringify boolean values (#51)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
  • Loading branch information
airmoi and pi0 committed Mar 31, 2022
1 parent f8ee0c0 commit 469dd88
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/query.ts
Expand Up @@ -35,7 +35,7 @@ export function parseQuery (paramsStr: string = ''): QueryObject {
}

export function encodeQueryItem (key: string, val: QueryValue): string {
if (typeof val === 'number') {
if (typeof val === 'number' || typeof val === 'boolean') {
val = String(val)
}
if (!val) {
Expand Down
1 change: 1 addition & 0 deletions test/query.test.ts
Expand Up @@ -11,6 +11,7 @@ describe('withQuery', () => {
{ input: '/?test', query: { foo: 0 }, out: '/?test&foo=0' },
{ input: '/?test', query: { foo: 1 }, out: '/?test&foo=1' },
{ input: '/?foo=1', query: { foo: 2 }, out: '/?foo=2' },
{ input: '/?foo=1', query: { foo: true, bar: false }, out: '/?foo=true&bar=false' },
{
input: '/',
query: { email: 'some email.com' },
Expand Down

0 comments on commit 469dd88

Please sign in to comment.