mirror of
https://github.com/typicode/json-server.git
synced 2025-08-02 11:32:47 +08:00
Exposing Link
in the header instead of Links
(#394)
- fix the small typo `Links` to `Link` - update relevant tests
This commit is contained in:
@ -153,7 +153,7 @@ module.exports = function (db, name) {
|
|||||||
// Slice result
|
// Slice result
|
||||||
if (_end || _limit || _page) {
|
if (_end || _limit || _page) {
|
||||||
res.setHeader('X-Total-Count', chain.size())
|
res.setHeader('X-Total-Count', chain.size())
|
||||||
res.setHeader('Access-Control-Expose-Headers', 'X-Total-Count' + (_page ? ', Links' : ''))
|
res.setHeader('Access-Control-Expose-Headers', 'X-Total-Count' + (_page ? ', Link' : ''))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_page) {
|
if (_page) {
|
||||||
|
@ -261,7 +261,7 @@ describe('Server', function () {
|
|||||||
.get('/list?_page=2')
|
.get('/list?_page=2')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('x-total-count', db.list.length.toString())
|
.expect('x-total-count', db.list.length.toString())
|
||||||
.expect('Access-Control-Expose-Headers', 'X-Total-Count, Links')
|
.expect('Access-Control-Expose-Headers', 'X-Total-Count, Link')
|
||||||
.expect(db.list.slice(10, 20))
|
.expect(db.list.slice(10, 20))
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
})
|
})
|
||||||
@ -281,7 +281,7 @@ describe('Server', function () {
|
|||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('x-total-count', db.list.length.toString())
|
.expect('x-total-count', db.list.length.toString())
|
||||||
.expect('link', link)
|
.expect('link', link)
|
||||||
.expect('Access-Control-Expose-Headers', 'X-Total-Count, Links')
|
.expect('Access-Control-Expose-Headers', 'X-Total-Count, Link')
|
||||||
.expect(db.list.slice(1, 2))
|
.expect(db.list.slice(1, 2))
|
||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user