Skip to content

Commit

Permalink
Merge 2782ebd into a20ec68
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanopretto committed Oct 7, 2016
2 parents a20ec68 + 2782ebd commit e7ffcc7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -5,7 +5,7 @@ module.exports = function normalizeQueryParams(params) {
var index = lowerCased.indexOf(key.toLowerCase());
if (index > -1) {
req.query[params[index]] = req.query[key];
delete req.query[key];
if (key !== params[index]) delete req.query[key];
}
});
next();
Expand Down
10 changes: 9 additions & 1 deletion test.js
Expand Up @@ -7,7 +7,8 @@ describe('normalize query params', function() {
beforeEach(function() {
req = {
query: {
someparam: 5
someparam: 5,
alreadyCorrectParam: 42
}
};
});
Expand All @@ -18,4 +19,11 @@ describe('normalize query params', function() {
done();
});
});

it('should not remove configured params that are passed correctly', function(done) {
normalizeQueryParams(['alreadyCorrectParam'])(req, null, function() {
expect(req.query.alreadyCorrectParam).to.equal(42);
done();
});
});
});

0 comments on commit e7ffcc7

Please sign in to comment.