Files
zulip/static/js/search_util.js
Anders Kaseorg 8bbb0d9193 js: Convert static/js/search_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00

23 lines
630 B
JavaScript

export function get_search_terms(input) {
const search_terms = input
.toLowerCase()
.split(",")
.map((s) => s.trim());
return search_terms;
}
export function vanilla_match(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));
}