mirror of
https://github.com/typicode/json-server.git
synced 2025-08-02 19:52:20 +08:00
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:
@ -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) {
|
||||
|
Reference in New Issue
Block a user