Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

left-sidebar: Use -, _, :, and / as additional topic word separators.

Aditya Kumar Kasaudhan899426613709
diff --git a/web/src/topic_list_data.ts b/web/src/topic_list_data.ts
index afc7cd6c79f..e0352a744cb 100644
--- a/web/src/topic_list_data.ts
+++ b/web/src/topic_list_data.ts
@@ -187,7 +187,13 @@ export function get_list_info(
}
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) {
diff --git a/web/tests/topic_list_data.test.js b/web/tests/topic_list_data.test.js
index aecbc330f6a..3a897bceeda 100644
--- a/web/tests/topic_list_data.test.js
+++ b/web/tests/topic_list_data.test.js
@@ -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);
+});