Skip to content

Commit 7c79fd4

Browse files
blueloverspi0
authored andcommitted
fix(utilities): avoid send xxx=undefined in query (#387)
1 parent 4605681 commit 7c79fd4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/core/utilities.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ export const parseQuery = queryString => {
1717
}
1818

1919
export const encodeQuery = queryObject => {
20-
return Object.keys(queryObject)
20+
return Object.entries(queryObject)
21+
.filter(([key, value]) => typeof value !== 'undefined')
2122
.map(
22-
key =>
23-
encodeURIComponent(key) + '=' + encodeURIComponent(queryObject[key])
23+
([key, value]) =>
24+
encodeURIComponent(key) + (value != null ? '=' + encodeURIComponent(value) : '')
2425
)
2526
.join('&')
2627
}

0 commit comments

Comments
 (0)