mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
search: Extract phrase_match to common.js.
Extracts phrase_match to common.js so it can be used by other components like integrations search.
This commit is contained in:
@@ -69,6 +69,25 @@ exports.password_warning = function (password, password_field) {
|
||||
return zxcvbn(password).feedback.warning || i18n.t("Password is too weak");
|
||||
};
|
||||
|
||||
exports.phrase_match = function (query, phrase) {
|
||||
// match "tes" to "test" and "stream test" but not "hostess"
|
||||
var i;
|
||||
query = query.toLowerCase();
|
||||
|
||||
phrase = phrase.toLowerCase();
|
||||
if (phrase.indexOf(query) === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var parts = phrase.split(' ');
|
||||
for (i = 0; i < parts.length; i += 1) {
|
||||
if (parts[i].indexOf(query) === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user