mirror of
https://github.com/feathersjs/feathers.git
synced 2026-02-01 17:37:38 +00:00
matcher now doesn't blow up with null values. Closes #46
This commit is contained in:
parent
4f822ae4ca
commit
6dc64d8d71
@ -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);
|
||||
|
||||
@ -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 () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user