2021-04-11 17:27:22 +02:00
|
|
|
export function get_search_terms(input: string): string[] {
|
2020-07-15 00:34:28 +02:00
|
|
|
const search_terms = input
|
|
|
|
.toLowerCase()
|
|
|
|
.split(",")
|
|
|
|
.map((s) => s.trim());
|
2018-07-29 16:11:48 +02:00
|
|
|
return search_terms;
|
2021-02-10 16:45:43 +01:00
|
|
|
}
|
2018-07-29 16:11:48 +02:00
|
|
|
|
2021-04-11 17:27:22 +02:00
|
|
|
export function vanilla_match(opts: {val: string; search_terms: string[]}): boolean {
|
2018-07-29 16:11:48 +02:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
2019-11-02 00:06:25 +01:00
|
|
|
const val = opts.val.toLowerCase();
|
2020-07-02 01:39:34 +02:00
|
|
|
return opts.search_terms.some((term) => val.includes(term));
|
2021-02-10 16:45:43 +01:00
|
|
|
}
|