Files
zulip/static/js/search_util.js
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00

27 lines
686 B
JavaScript

"use strict";
exports.get_search_terms = function (input) {
const search_terms = input
.toLowerCase()
.split(",")
.map((s) => 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 opts.search_terms.some((term) => val.includes(term));
};
window.search_util = exports;