From 9c58967a3810b053194402b594b3b9dd92bb7f45 Mon Sep 17 00:00:00 2001 From: Hans Klunder Date: Tue, 20 May 2025 16:50:27 +0000 Subject: [PATCH] fix: fix wildcard position detection --- asyncPersistence.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/asyncPersistence.js b/asyncPersistence.js index a88f8fc..a69d42f 100644 --- a/asyncPersistence.js +++ b/asyncPersistence.js @@ -87,11 +87,15 @@ function longestCommonPrefix (patterns) { } function wildCardPosition (pattern) { + // return the first position of a wildcard or -1 if one is found + // if present wildcard_some is always the last character of the pattern const oneIndex = pattern.indexOf(qlobberOpts.wildcard_one) - const someIndex = pattern.indexOf(qlobberOpts.wildcard_some) - if (oneIndex > someIndex) { + // we found oneIndex, so it must be the first one + if (oneIndex !== -1) { return oneIndex } + // check for one wildcard_some + const someIndex = pattern.indexOf(qlobberOpts.wildcard_some) return someIndex }