3
0
Fork 0
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:
Dragory 2021-10-17 08:03:38 +03:00
parent aea6999753
commit 44f5b77cc7
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
5 changed files with 85 additions and 43 deletions

View 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);
}