util: Use the same regex as the backend for wildcard mentions.

This commit is contained in:
Alex Vandiver 2024-03-21 19:11:29 +00:00 committed by Tim Abbott
parent 89a22fb076
commit 92fa9ee78c
2 changed files with 4 additions and 2 deletions

View File

@ -195,11 +195,11 @@ export class CachedValue<T> {
}
export function find_stream_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)\*{2})/);
if (mention === null) {
return null;
}
return mention[3];
return mention[2];
}
export const move_array_elements_to_front = function util_move_array_elements_to_front<T>(

View File

@ -168,6 +168,8 @@ run_test("wildcard_mentions_regexp", () => {
const messages_with_everyone_mentions = [
"@**everyone**",
'"@**everyone**"',
"@**everyone**: Look at this!",
"some text before @**everyone** some text after",
"@**everyone** some text after only",
"some text before only @**everyone**",