-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrectly matches [1-5]
against [1-5]
#71
Comments
Did you try picomatch('[1-5]', { literalBrackets: true })('[1-5]'); I haven't tried it, let me know if this doesn't work.
Have you run the unit tests with that check disabled? How many tests fail? Also, why? Why wouldn't that match? It makes no sense to say that it should fail if the glob exactly matches the input string. |
Hi @jonschlinkert, thanks for the fast reply!
This is not about
No. I will do that.
It shouldn't match because the glob pattern Consider a scenario in which I am looking for files whose names are a single digit. I'd use the pattern |
Did you try setting
Brackets are legal path characters. We need to handle literal matching as well.
Thanks, I was asking about your use case, not how regular expression work.
Malicious? Lol k. Consider a scenario in which I am looking for files whose names are a single digit. I'd use the pattern [0-9]. You could do this: const isMatch = pattern => {
const matcher = picomatch(pattern);
return input => pattern !== input && matcher(input);
}; |
Interesting, after changing the code to the way I thought it should be, I get 15 failing tests:
Looks like that check was being useful to work around a few edge cases... |
Hmm, I just tried
Of course, but only if the user requested so :) By the way now I have a tangential documentation question: it says that the default value for
Sorry 😅 |
I have just asked a related question on Unix SE |
Ok, thanks for letting me know. Marking as a bug.
Since brackets in bash have special significance that only makes sense in the terminal, picomatch is able to provide more regex matching features you won't find in bash.
no need. thanks for helping me uncover a bug. |
By the way, for the record, after my modification attempt, one of the assertions that failed is the following: Line 88 in 4a510d7
However, interestingly, by trying on a real bash terminal, the real behavior also disagrees with this assertion! $ mkdir temp && cd temp
$ touch \*
$ touch \\\*
$ ls
'*' '\*'
$ ls \*
'*' The last command shows that the |
picomatch('[1-5]')('[1-5]')
false
true
Apparently this mistake is caused explicitly:
picomatch/lib/picomatch.js
Line 128 in 4a510d7
Why? This should not match. Please remove this check.
As a workaround, I am using
picomatch.makeRe(pattern).test(str)
instead ofpicomatch(pattern)(str)
.The text was updated successfully, but these errors were encountered: