Skip to content

Commit 6a41f6d

Browse files
authored
fix: wildcard position detection (#123)
1 parent 043da05 commit 6a41f6d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

asyncPersistence.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ function longestCommonPrefix (patterns) {
8787
}
8888

8989
function wildCardPosition (pattern) {
90+
// return the first position of a wildcard or -1 if one is found
91+
// if present wildcard_some is always the last character of the pattern
9092
const oneIndex = pattern.indexOf(qlobberOpts.wildcard_one)
91-
const someIndex = pattern.indexOf(qlobberOpts.wildcard_some)
92-
if (oneIndex > someIndex) {
93+
// we found oneIndex, so it must be the first one
94+
if (oneIndex !== -1) {
9395
return oneIndex
9496
}
97+
// check for one wildcard_some
98+
const someIndex = pattern.indexOf(qlobberOpts.wildcard_some)
9599
return someIndex
96100
}
97101

0 commit comments

Comments
 (0)