Skip to content

Commit

Permalink
fix: avoid to stringify undefined query values as 'undefined' string
Browse files Browse the repository at this point in the history
fix #23
  • Loading branch information
Guria committed Mar 7, 2016
1 parent c50b932 commit 50ce97e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function compileRoute (route, options) {
pathParams[key] = values[key]
}
} else {
queryParams[key] = values[key]
if (typeof values[key] !== 'undefined') queryParams[key] = values[key]
}
})

Expand Down
11 changes: 11 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,17 @@ module.exports = {
test.done()
},

'should not stringify undefined query params': function (test) {
var mapper = urlMapper({ query: true })

test.equal(mapper.stringify('/:foo', {
foo: 'bar',
bar: undefined
}), '/bar')

test.done()
},

'should parse stringified object including params not defined in route': function (test) {
var mapper = urlMapper({ query: true })
var object = {
Expand Down

0 comments on commit 50ce97e

Please sign in to comment.