extglob bug: '*(?)' pattern wrongly excludes files with extensions
ds300 opened this issue · comments
I'm doing some generative tests using minimatch as a gold standard, and ran into one niche issue that seems to be a bug with minimatch:
> require('minimatch').makeRe('/*(?)').test('/ok')
true ✅
> require('minimatch').makeRe('/*(?)').test('/ok.txt')
false ❌ I would expect this to also be true
I'm interpreting *(?)
in this situation as
0 or more occurrences of any character except slash, failing if the first character is a dot
The compiled regex is
/^\/(?:(?!\.)[^/])*$/
but i think that star should be nudged over into the parens
/^\/(?:(?!\.)[^/]*)$/
Hm, yes, the generated regexp is noting that the ? is matching the first item in a path portion, and thus disallowing a dot. However, it needs to treat that as effectively (not a dot)(anything)*
in repeated cases.
Putting the * inside the paren would fix it in this specific case, but the paren in question corresponds to the ) in *(...|...)
, and the dot prevention needs to be attached to the sub-pattern, to support stuff like ?(*|.a)
where one allows dots and another doesn't.
So the fix will be a little more complicated.