Skip to content

Commit

Permalink
fix(utilities): avoid send xxx=undefined in query (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluelovers authored and pi0 committed Jun 24, 2019
1 parent 4605681 commit 7c79fd4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/core/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ export const parseQuery = queryString => {
}

export const encodeQuery = queryObject => {
return Object.keys(queryObject)
return Object.entries(queryObject)
.filter(([key, value]) => typeof value !== 'undefined')
.map(
key =>
encodeURIComponent(key) + '=' + encodeURIComponent(queryObject[key])
([key, value]) =>
encodeURIComponent(key) + (value != null ? '=' + encodeURIComponent(value) : '')
)
.join('&')
}
Expand Down

0 comments on commit 7c79fd4

Please sign in to comment.