mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 19:17:19 +00:00
perf(automod): also merge regexes in match_links, match_words
This commit is contained in:
parent
aea6999753
commit
44f5b77cc7
5 changed files with 85 additions and 43 deletions
6
backend/src/utils/mergeWordsIntoRegex.ts
Normal file
6
backend/src/utils/mergeWordsIntoRegex.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import escapeStringRegexp from "escape-string-regexp";
|
||||
|
||||
export function mergeWordsIntoRegex(words: string[], flags?: string) {
|
||||
const source = words.map((word) => `(?:${escapeStringRegexp(word)})`).join("|");
|
||||
return new RegExp(source, flags);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue