mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
util: Use the same regex as the backend for wildcard mentions.
This commit is contained in:
committed by
Tim Abbott
parent
89a22fb076
commit
92fa9ee78c
@@ -195,11 +195,11 @@ export class CachedValue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function find_stream_wildcard_mentions(message_content: string): string | null {
|
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) {
|
if (mention === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return mention[3];
|
return mention[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const move_array_elements_to_front = function util_move_array_elements_to_front<T>(
|
export const move_array_elements_to_front = function util_move_array_elements_to_front<T>(
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ run_test("wildcard_mentions_regexp", () => {
|
|||||||
|
|
||||||
const messages_with_everyone_mentions = [
|
const messages_with_everyone_mentions = [
|
||||||
"@**everyone**",
|
"@**everyone**",
|
||||||
|
'"@**everyone**"',
|
||||||
|
"@**everyone**: Look at this!",
|
||||||
"some text before @**everyone** some text after",
|
"some text before @**everyone** some text after",
|
||||||
"@**everyone** some text after only",
|
"@**everyone** some text after only",
|
||||||
"some text before only @**everyone**",
|
"some text before only @**everyone**",
|
||||||
|
|||||||
Reference in New Issue
Block a user