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

fix: avoid infinite loop for square brackets custom modifier #167

Merged
merged 1 commit into from
Mar 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/generateRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function* candidatePermutations(candidate, lastIndex = Infinity) {

let dashIdx

if (candidate.endsWith(']')) {
if (candidate.endsWith(']', /*length*/ lastIndex + 1)) {
dashIdx = candidate.lastIndexOf('[') - 1
} else {
dashIdx = candidate.lastIndexOf('-', lastIndex)
Expand All @@ -33,7 +33,7 @@ function* candidatePermutations(candidate, lastIndex = Infinity) {
return
}

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

yield [prefix, modifier]
Expand Down