Skip to content

Commit

Permalink
Prevent empty strings / arrays from passing filter (#19)
Browse files Browse the repository at this point in the history
* Prevent empty strings / arrays from passing filter

* Update src/utils/objectToUrlParams.ts

Co-authored-by: John Richard Chipps-Harding <[email protected]>

Co-authored-by: John Richard Chipps-Harding <[email protected]>
  • Loading branch information
PauloMFJ and John Richard Chipps-Harding authored Nov 15, 2021
1 parent 7afd4f9 commit e6dac46
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/objectToUrlParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface UrlDataProps {

export default function objectToUrlParams(data: UrlDataProps) {
const params = Object.entries(data)
.filter(([, value]) => value !== undefined && value !== null)
.filter(([, value]) => value)
.map(
([key, value]) =>
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
Expand Down

0 comments on commit e6dac46

Please sign in to comment.