From 202375c6dc96cfa6394578fd062884fa14ffe9c0 Mon Sep 17 00:00:00 2001 From: makinoy Date: Tue, 18 Jul 2017 17:02:40 +0900 Subject: [PATCH 1/2] Fix --- lib/filtr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filtr.js b/lib/filtr.js index bfdee21..843eb62 100644 --- a/lib/filtr.js +++ b/lib/filtr.js @@ -87,7 +87,7 @@ _eq = function (a, b) { if (a instanceof Array) { return a.some(function(v) {return _eq(v, b)}) } - if (b instanceof RegExp) { + if (a != null && b instanceof RegExp) { return b.test(a); } if (b === null) { From 20161e954844e0ec1f1181fe74d70b98328c1f79 Mon Sep 17 00:00:00 2001 From: makinoy Date: Tue, 18 Jul 2017 17:05:40 +0900 Subject: [PATCH 2/2] Add a test case --- test/query.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/query.js b/test/query.js index cb7a021..3f48e16 100644 --- a/test/query.js +++ b/test/query.js @@ -330,6 +330,12 @@ describe('Query', function () { Q.test({sets: ['Firefox', 'abc']}, {type: 'single'}).should.be.false; }); + it('should regexp $eq work appropriately', function () { + var query = {'test': /f/} + , Q = filtr(query); + Q.stack.should.have.length(1); + Q.test({}, {type: 'single'}).should.be.false; + }); });