Skip to content

Commit

Permalink
Partial match previous search terms in streams page.
Browse files Browse the repository at this point in the history
Before in a query string like:

“all, s, verona”

It would only strong match the first two terms, but now it’ll partial
string match all terms equally.
  • Loading branch information
Brock Whittaker authored and timabbott committed Dec 31, 2016
1 parent 9834731 commit 338dcfc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend_tests/node_tests/subs.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ i18n.init({
assert(elem_3.hasClass("notdisplayed"));

subs.filter_table({input: "Den, Pol", subscribed_only: false});
assert(elem_1.hasClass("notdisplayed"));
assert(!elem_1.hasClass("notdisplayed"));
assert(!elem_2.hasClass("notdisplayed"));
assert(elem_3.hasClass("notdisplayed"));

Expand Down
6 changes: 3 additions & 3 deletions static/js/subs.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,10 @@ function stream_matches_query(query, sub) {
var flag = true;
flag = flag && (function () {
var sub_name = sub.name.toLowerCase();
var matches_list = search_terms.indexOf(sub_name) > -1;
var matches_last_val = sub_name.match(search_terms[search_terms.length - 1]);

return matches_list || matches_last_val;
return _.any(search_terms, function (o) {
return new RegExp(o).test(sub_name);
});
}());
flag = flag && ((sub.subscribed || !query.subscribed_only) ||
sub.data_temp_view === "true");
Expand Down

0 comments on commit 338dcfc

Please sign in to comment.