Skip to content
Permalink
Browse files
fix(utilities): avoid send xxx=undefined in query (#387)
  • Loading branch information
bluelovers authored and pi0 committed Jun 24, 2019
1 parent 4605681 commit 7c79fd4284ea6d3a9de36a87240f5e3e6abde87b
Showing 1 changed file with 4 additions and 3 deletions.
@@ -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('&')
}

0 comments on commit 7c79fd4

Please sign in to comment.