mirror of https://github.com/zulip/zulip.git
left-sidebar: Use -, _, :, and / as additional topic word separators.
Previously, only spaces were used as word separators when searching for topics. This meant that searching for "support" would not find a topic named "topic_support" or "topic/support," which could lead to unexpected results. To address this, hyphen (-), underscore (_), colon (:), and slash (/) have been added as additional word separators for topic filtering in the left sidebar, as these characters are commonly used as separators in topic names. Fixes: #31844
This commit is contained in:
parent
cf879a5f48
commit
8994266137
|
@ -187,7 +187,13 @@ export function get_list_info(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomed) {
|
if (zoomed) {
|
||||||
topic_names = util.filter_by_word_prefix_match(topic_names, search_term, (item) => item);
|
const word_separator_regex = /[\s/:_-]/; // Use -, _, :, / as word separators in addition to spaces.
|
||||||
|
topic_names = util.filter_by_word_prefix_match(
|
||||||
|
topic_names,
|
||||||
|
search_term,
|
||||||
|
(topic) => topic,
|
||||||
|
word_separator_regex,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream_muted && !zoomed) {
|
if (stream_muted && !zoomed) {
|
||||||
|
|
|
@ -404,3 +404,41 @@ test("get_list_info unreads", ({override}) => {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("get_list_info with specific topics and searches", () => {
|
||||||
|
let list_info;
|
||||||
|
|
||||||
|
function add_topic_message(topic_name, message_id) {
|
||||||
|
stream_topic_history.add_message({
|
||||||
|
stream_id: general.stream_id,
|
||||||
|
topic_name,
|
||||||
|
message_id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
add_topic_message("BF-2924 zulip", 1001);
|
||||||
|
add_topic_message("tech_support/escalation", 1002);
|
||||||
|
|
||||||
|
list_info = get_list_info(true, "2924");
|
||||||
|
assert.equal(list_info.items.length, 1);
|
||||||
|
assert.equal(list_info.items[0].topic_name, "BF-2924 zulip");
|
||||||
|
|
||||||
|
list_info = get_list_info(true, "support/escalation");
|
||||||
|
assert.equal(list_info.items.length, 1);
|
||||||
|
assert.equal(list_info.items[0].topic_name, "tech_support/escalation");
|
||||||
|
|
||||||
|
list_info = get_list_info(true, "support");
|
||||||
|
assert.equal(list_info.items.length, 1);
|
||||||
|
assert.equal(list_info.items[0].topic_name, "tech_support/escalation");
|
||||||
|
|
||||||
|
list_info = get_list_info(true, "zulip");
|
||||||
|
assert.equal(list_info.items.length, 1);
|
||||||
|
assert.equal(list_info.items[0].topic_name, "BF-2924 zulip");
|
||||||
|
|
||||||
|
list_info = get_list_info(true, "SUPPORT");
|
||||||
|
assert.equal(list_info.items.length, 1);
|
||||||
|
assert.equal(list_info.items[0].topic_name, "tech_support/escalation");
|
||||||
|
|
||||||
|
list_info = get_list_info(true, "nonexistent");
|
||||||
|
assert.equal(list_info.items.length, 0);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue