mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 08:45:05 +00:00
DEV: tiny refactor in watched words (#12969)
This commit is contained in:
parent
b61d4663ec
commit
82ecd9fdd5
@ -11,16 +11,14 @@ function findAllMatches(text, matchers, useRegExp) {
|
|||||||
|
|
||||||
if (useRegExp) {
|
if (useRegExp) {
|
||||||
const maxMatches = 100;
|
const maxMatches = 100;
|
||||||
let index = 0;
|
let count = 0;
|
||||||
|
|
||||||
matchers.forEach((matcher) => {
|
matchers.forEach((matcher) => {
|
||||||
let match;
|
let match;
|
||||||
while (
|
while (
|
||||||
(match = matcher.pattern.exec(text)) !== null &&
|
(match = matcher.pattern.exec(text)) !== null &&
|
||||||
index < maxMatches
|
count++ < maxMatches
|
||||||
) {
|
) {
|
||||||
index++;
|
|
||||||
|
|
||||||
matches.push({
|
matches.push({
|
||||||
index: match.index,
|
index: match.index,
|
||||||
text: match[0],
|
text: match[0],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user