mirror of
https://github.com/typicode/json-server.git
synced 2025-07-30 13:42:11 +08:00
@ -92,6 +92,10 @@ module.exports = (db, name) => {
|
|||||||
|
|
||||||
if (q) {
|
if (q) {
|
||||||
// Full-text search
|
// Full-text search
|
||||||
|
if (Array.isArray(q)) {
|
||||||
|
q = q[0]
|
||||||
|
}
|
||||||
|
|
||||||
q = q.toLowerCase()
|
q = q.toLowerCase()
|
||||||
|
|
||||||
chain = chain.filter((obj) => {
|
chain = chain.filter((obj) => {
|
||||||
|
@ -198,6 +198,14 @@ describe('Server', () => {
|
|||||||
.expect(200, done)
|
.expect(200, done)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should ignore duplicate q query parameters', (done) => {
|
||||||
|
request(server)
|
||||||
|
.get('/comments?q=foo&q=bar')
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect([ db.comments[0] ])
|
||||||
|
.expect(200, done)
|
||||||
|
})
|
||||||
|
|
||||||
it('should support filtering by boolean value false', (done) => {
|
it('should support filtering by boolean value false', (done) => {
|
||||||
request(server)
|
request(server)
|
||||||
.get('/comments?published=false')
|
.get('/comments?published=false')
|
||||||
|
Reference in New Issue
Block a user