matcher now doesn't blow up with null values. Closes #46

This commit is contained in:
Eric Kryski 2016-11-30 13:49:36 -07:00 committed by David Luecke
parent 4f822ae4ca
commit 6dc64d8d71
2 changed files with 11 additions and 1 deletions

View File

@ -152,7 +152,7 @@ export function matcher (originalQuery) {
}
return _.every(query, (value, key) => {
if (typeof value === 'object') {
if (value !== null && typeof value === 'object') {
return _.every(value, (target, filterType) => {
if (specialFilters[filterType]) {
const filter = specialFilters[filterType](key, target);

View File

@ -370,6 +370,16 @@ describe('feathers-commons utils', () => {
expect(!matches({ name: 'Eric', counter: 1 })).to.be.ok;
expect(matches({ name: 'Marshall', counter: 0 })).to.be.ok;
});
it('with null values', () => {
const matches = matcher({
counter: null,
name: { $in: ['Eric', 'Marshall'] }
});
expect(!matches({ name: 'Eric', counter: 0 })).to.be.ok;
expect(matches({ name: 'Marshall', counter: null })).to.be.ok;
});
});
describe('makeUrl', function () {