Commit 245a40d0 by preetwinder

Support multiline string search with the % wildcard

1 parent f864e6e4
......@@ -415,7 +415,7 @@
return new RegExp("^" + stringEscapeRegexpCharacters(string) + "$");
}
return new RegExp("^" + stringEscapeRegexpCharacters(string)
.replace(regexp_percent, '.*')
.replace(regexp_percent, '[\\s\\S]*')
.replace(regexp_underscore, '.') + "$");
}
......
......@@ -313,4 +313,48 @@
});
test('Docs with space, tab, and newline', function () {
var doc_list = [
{"identifier": "a"},
{"identifier": "a "}
];
stop();
expect(3);
jIO.QueryFactory.create('identifier: "%a%"').exec(
doc_list
).then(function (doc_list) {
deepEqual(doc_list, [
{"identifier": "a"},
{"identifier": "a "}
], 'Document with space is matched');
doc_list = [
{"identifier": "a"},
{"identifier": "a \t"}
];
return jIO.QueryFactory.create('identifier: "%a%"').
exec(doc_list);
}).then(function (doc_list) {
deepEqual(doc_list, [
{"identifier": "a"},
{"identifier": "a \t"}
], 'Document with tab is matched');
doc_list = [
{"identifier": "a"},
{"identifier": "a\n"},
{"identifier": "\na\nb\nc\n"}
];
return jIO.QueryFactory.create('identifier: "%a%"').
exec(doc_list);
}).then(function (doc_list) {
deepEqual(doc_list, [
{"identifier": "a"},
{"identifier": "a\n"},
{"identifier": "\na\nb\nc\n"}
], 'Documents with newlines are matched');
}).always(start);
});
}));
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!