Skip to content

Commit

Permalink
fix: add typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 15, 2022
1 parent f2f188f commit a9626ff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
encodeQueryValue
} from './encoding'

export type QueryValue = string | string[] | number | number[] | undefined
export type QueryValue = string | string[] | undefined
export type QueryObject = Record<string, QueryValue>

export function parseQuery (paramsStr: string = ''): QueryObject {
Expand Down Expand Up @@ -35,7 +35,10 @@ export function parseQuery (paramsStr: string = ''): QueryObject {
}

export function encodeQueryItem (key: string, val: QueryValue): string {
if (!val && val !== 0) {
if (typeof val === 'number') {
val = String(val)
}
if (!val) {
return encodeQueryKey(key)
}

Expand Down

0 comments on commit a9626ff

Please sign in to comment.