Skip to content

Commit

Permalink
refactor: change implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Mar 23, 2022
1 parent df69c33 commit 687b1e4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/matches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ function matches(
if (matcher instanceof Function) {
return matcher(normalizedText, node)
} else if (matcher instanceof RegExp) {
return new RegExp(matcher).test(normalizedText)
const match = matcher.test(normalizedText)
if (matcher.global) {
matcher.lastIndex = 0
}
return match
} else {
return normalizedText === String(matcher)
}
Expand Down

0 comments on commit 687b1e4

Please sign in to comment.