mirror of https://github.com/zulip/zulip.git
util: Do not use look-behind in wildcard mention checks.
92fa9ee78c
switched this regex to match the server-side regex, but
Safari < 16.4 does not support look-behind in regexes.
Switch to matching on start-of-string or a positive character class.
This commit is contained in:
parent
6d5243148a
commit
01860422af
|
@ -195,7 +195,10 @@ 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})/);
|
||||
// We cannot use the exact same regex as the server side users (in zerver/lib/mention.py)
|
||||
// because Safari < 16.4 does not support look-behind assertions. Reframe the lookbehind of a
|
||||
// negative character class as a start-of-string or positive character class.
|
||||
const mention = message_content.match(/(?:^|[\s"'(/<[{])(@\*{2}(all|everyone|stream)\*{2})/);
|
||||
if (mention === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -170,6 +170,8 @@ run_test("wildcard_mentions_regexp", () => {
|
|||
"@**everyone**",
|
||||
'"@**everyone**"',
|
||||
"@**everyone**: Look at this!",
|
||||
"The <@**everyone**> channel",
|
||||
'I have to say "@**everyone**" to ding the bell',
|
||||
"some text before @**everyone** some text after",
|
||||
"@**everyone** some text after only",
|
||||
"some text before only @**everyone**",
|
||||
|
|
Loading…
Reference in New Issue