diff --git a/src/server/router/plural.js b/src/server/router/plural.js index 0c8b1173b..5ac910c36 100644 --- a/src/server/router/plural.js +++ b/src/server/router/plural.js @@ -92,6 +92,10 @@ module.exports = (db, name) => { if (q) { // Full-text search + if (Array.isArray(q)) { + q = q[0] + } + q = q.toLowerCase() chain = chain.filter((obj) => { diff --git a/test/server/plural.js b/test/server/plural.js index 8e1c55f32..ca918bca6 100644 --- a/test/server/plural.js +++ b/test/server/plural.js @@ -198,6 +198,14 @@ describe('Server', () => { .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) => { request(server) .get('/comments?published=false')