Add support for query params in rewrite targets (#373)

* Add support for query params in rewrite targets

Re-parse the rewrite target to add query params, fixes #372

* Use lodash for Object.assign for node v0.12 compatibility
This commit is contained in:
Ashley L Hill
2016-09-30 20:25:13 -04:00
committed by typicode
parent e5473811b1
commit b06bc27d91
2 changed files with 15 additions and 1 deletions

View File

@ -74,7 +74,8 @@ describe('Server', function () {
server.use(jsonServer.defaults())
server.use(jsonServer.rewriter({
'/api/': '/',
'/blog/posts/:id/show': '/posts/:id'
'/blog/posts/:id/show': '/posts/:id',
'/comments/special/:userId-:body': '/comments/?userId=:userId&body=:body'
}))
server.use(router)
})
@ -647,6 +648,13 @@ describe('Server', function () {
.expect(db.posts[0])
.end(done)
})
it('should rewrite using params and query', function (done) {
request(server)
.get('/comments/special/1-quux')
.expect([db.comments[4]])
.end(done)
})
})
describe('router.render', function (done) {