Skip to content

Commit

Permalink
Fix duplicate query params error (Issue: typicode#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwardio committed Feb 5, 2017
1 parent 2c435ee commit a853636
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/server/router/plural.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
8 changes: 8 additions & 0 deletions test/server/plural.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit a853636

Please sign in to comment.