Files
zulip/static/js/search_util.js
Anders Kaseorg 28f3dfa284 js: Automatically convert var to let and const in most files.
This commit was originally automatically generated using `tools/lint
--only=eslint --fix`.  It was then modified by tabbott to contain only
changes to a set of files that are unlikely to result in significant
merge conflicts with any open pull request, excluding about 20 files.
His plan is to merge the remaining changes with more precise care,
potentially involving merging parts of conflicting pull requests
before running the `eslint --fix` operation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-03 12:42:39 -08:00

28 lines
746 B
JavaScript

exports.get_search_terms = function (input) {
const search_terms = input.toLowerCase().split(",").map(function (s) {
return s.trim();
});
return search_terms;
};
exports.vanilla_match = function (opts) {
/*
This is a pretty vanilla search criteria
where we see if any of our search terms
is in our value. When in doubt we should use
this for all Zulip filters, but we may
have more complicated use cases in some
places.
This is case insensitive.
*/
const val = opts.val.toLowerCase();
return _.any(opts.search_terms, function (term) {
if (val.indexOf(term) !== -1) {
return true;
}
});
};
window.search_util = exports;