File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -117,11 +117,6 @@ const mentionsMarkdownPlugin = <
117117 . filter ( Boolean )
118118 . map ( escapeRegExp ) ;
119119
120- const mentionedUsersRegex = new RegExp (
121- mentioned_usernames . map ( ( username ) => `@${ username } ` ) . join ( '|' ) ,
122- 'g' ,
123- ) ;
124-
125120 function replace ( match : string ) {
126121 const usernameOrId = match . replace ( '@' , '' ) ;
127122 const user = mentioned_users . find (
@@ -135,6 +130,13 @@ const mentionsMarkdownPlugin = <
135130 }
136131
137132 const transform = < T extends unknown > ( markdownAST : T ) => {
133+ if ( ! mentioned_usernames . length ) {
134+ return markdownAST ;
135+ }
136+ const mentionedUsersRegex = new RegExp (
137+ mentioned_usernames . map ( ( username ) => `@${ username } ` ) . join ( '|' ) ,
138+ 'g' ,
139+ ) ;
138140 findAndReplace ( markdownAST , mentionedUsersRegex , replace ) ;
139141 return markdownAST ;
140142 } ;
You can’t perform that action at this time.
0 commit comments