File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -83,9 +83,15 @@ const useStyles = makeStyles((theme) => ({
8383} ) ) ;
8484
8585const makeMentionRE = ( username ) => {
86- username = username . replace ( / [ \\ ^ $ . * + ? ( ) [ \] { } | ] / g, "\\$&" ) ;
87- username = username . replace ( / ^ a n o n y m o u s / i, "($&)?" ) ;
88- return new RegExp ( `@(all|${ username } )(\\W|$)` , "iu" ) ;
86+ username = username . toLowerCase ( ) . replace ( / [ \\ ^ $ . * + ? ( ) [ \] { } | ] / g, "\\$&" ) ;
87+ var anon = "" ;
88+ const anonIdx = username . indexOf ( "anonymous " ) ;
89+ if ( anonIdx !== - 1 ) {
90+ anon = `(${ username . slice ( 0 , anonIdx + 10 ) } )?` ;
91+ username = username . slice ( anonIdx + 10 ) ;
92+ }
93+ const parts = username . split ( / \s + / ) . filter ( ( s ) => s ) ;
94+ return new RegExp ( `(\\W|^)@(all|${ anon } (${ parts . join ( "|" ) } ))(\\W|$)` , "iu" ) ;
8995} ;
9096
9197const emojiRE = / : ( [ a - z 0 - 9 _ + - ] + ) : / g;
You can’t perform that action at this time.
0 commit comments