diff --git a/src/backend.memory.js b/src/backend.memory.js index c75f6f6f..ece95bd2 100644 --- a/src/backend.memory.js +++ b/src/backend.memory.js @@ -142,9 +142,12 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {}; this._applyFreeTextQuery = function(results, queryObj) { if (queryObj.q) { var terms = queryObj.q.split(' '); + var patterns=_.map(terms, function(term) { + return new RegExp(term.toLowerCase());; + }); results = _.filter(results, function(rawdoc) { var matches = true; - _.each(terms, function(term) { + _.each(patterns, function(pattern) { var foundmatch = false; _.each(self.fields, function(field) { var value = rawdoc[field.id]; @@ -155,7 +158,7 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {}; value = ''; } // TODO regexes? - foundmatch = foundmatch || (value.toLowerCase() === term.toLowerCase()); + foundmatch = foundmatch || (pattern.test(value.toLowerCase())); // TODO: early out (once we are true should break to spare unnecessary testing) // if (foundmatch) return true; }); diff --git a/test/view.map.test.js b/test/view.map.test.js index 1efd3d83..698c22e6 100644 --- a/test/view.map.test.js +++ b/test/view.map.test.js @@ -177,7 +177,7 @@ test('Popup - Custom', function () { assertPresent(popup); var text = popup.html(); - ok((text.indexOf('