Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
util: Fix the 'find_wildcard_mentions' function.
Prakhar Pratyushb274169ccc11
diff --git a/web/src/util.ts b/web/src/util.tsindex 244ddc6cf69..d18d5264841 100644--- a/web/src/util.ts+++ b/web/src/util.ts@@ -193,7 +193,7 @@ export class CachedValue<T> {}export function find_wildcard_mentions(message_content: string): string | null {- const mention = message_content.match(/(^|\s)(@\*{2}(all|everyone|stream)\*{2})($|\s)/);+ const mention = message_content.match(/(^|\s)(@\*{2}(all|everyone|stream|topic)\*{2})($|\s)/);if (mention === null) {return null;}diff --git a/web/tests/util.test.js b/web/tests/util.test.jsindex 5dcf1c4f6e7..ddcaf950387 100644--- a/web/tests/util.test.js+++ b/web/tests/util.test.js@@ -148,7 +148,7 @@ run_test("random_int", () => {});});-run_test("all_and_everyone_mentions_regexp", () => {+run_test("wildcard_mentions_regexp", () => {const messages_with_all_mentions = ["@**all**","some text before @**all** some text after",@@ -170,6 +170,13 @@ run_test("all_and_everyone_mentions_regexp", () => {"some text before only @**stream**",];+ const messages_with_topic_mentions = [+ "@**topic**",+ "some text before @**topic** some text after",+ "@**topic** some text after only",+ "some text before only @**topic**",+ ];+const messages_without_all_mentions = ["@all","some text before @all some text after",@@ -197,6 +204,15 @@ run_test("all_and_everyone_mentions_regexp", () => {"some_email@**stream**.com",];+ const messages_without_topic_mentions = [+ "some text before @topic some text after",+ "@topic",+ "`@topic`",+ "[email protected]",+ "`@**topic**`",+ "some_email@**topic**.com",+ ];+let i;for (i = 0; i < messages_with_all_mentions.length; i += 1) {assert.ok(util.find_wildcard_mentions(messages_with_all_mentions[i]));@@ -210,6 +226,10 @@ run_test("all_and_everyone_mentions_regexp", () => {assert.ok(util.find_wildcard_mentions(messages_with_stream_mentions[i]));}+ for (i = 0; i < messages_with_topic_mentions.length; i += 1) {+ assert.ok(util.find_wildcard_mentions(messages_with_topic_mentions[i]));+ }+for (i = 0; i < messages_without_all_mentions.length; i += 1) {assert.ok(!util.find_wildcard_mentions(messages_without_everyone_mentions[i]));}@@ -221,6 +241,10 @@ run_test("all_and_everyone_mentions_regexp", () => {for (i = 0; i < messages_without_stream_mentions.length; i += 1) {assert.ok(!util.find_wildcard_mentions(messages_without_stream_mentions[i]));}++ for (i = 0; i < messages_without_topic_mentions.length; i += 1) {+ assert.ok(!util.find_wildcard_mentions(messages_without_topic_mentions[i]));+ }});run_test("move_array_elements_to_front", () => {