Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit a4df8ee

Browse files
committed
fix: avoid infinite loop for square brackets custom modifier
1 parent c404bc4 commit a4df8ee

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib/generateRules.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function* candidatePermutations(candidate, lastIndex = Infinity) {
2323

2424
let dashIdx
2525

26-
if (candidate.endsWith(']')) {
26+
if (candidate.endsWith(']', /*length*/ lastIndex + 1)) {
2727
dashIdx = candidate.lastIndexOf('[') - 1
2828
} else {
2929
dashIdx = candidate.lastIndexOf('-', lastIndex)
@@ -33,7 +33,7 @@ function* candidatePermutations(candidate, lastIndex = Infinity) {
3333
return
3434
}
3535

36-
let prefix = candidate.slice(0, dashIdx)
36+
let prefix = candidate.slice(0, candidate.charAt(dashIdx) === '-' ? dashIdx : dashIdx + 1)
3737
let modifier = candidate.slice(dashIdx + 1)
3838

3939
yield [prefix, modifier]

0 commit comments

Comments
 (0)