Skip to content
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

Can't match **.internal-test.js #99

Open
jakobrosenberg opened this issue Nov 20, 2021 · 3 comments
Open

Can't match **.internal-test.js #99

jakobrosenberg opened this issue Nov 20, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@jakobrosenberg
Copy link

I would expect the below to be true

const isMatch = picomatch('**.internal-test.js')
isMatch('my-tests/some-spec.internal-test.js') // false

However this works

const regex = picomatch.toRegex(picomatch.parse('**.internal-test.js').output)
regex.test('my-tests/some-spec.internal-test.js') // true
@jakobrosenberg
Copy link
Author

Fixed with by changing glob to **/*.internal-test.js

@jakobrosenberg
Copy link
Author

I noticed this inconsistency. Not sure if this is by design or a bug. To err on the side of caution, I'll reopen the issue.

import picomatch from "picomatch";

const isMatch1 = picomatch('**/*.dash-thing.js')
const isMatch2 = picomatch('**/*.thing.js')
const isMatch3 = picomatch('**.dash-thing.js')
const isMatch4 = picomatch('**.thing.js')

console.log(isMatch1('somepath/test.dash-thing.js')) // true
console.log(isMatch2('somepath/test.thing.js'))      // true
console.log(isMatch3('somepath/test.dash-thing.js')) // false
console.log(isMatch4('somepath/test.thing.js'))      // true

@jonschlinkert
Copy link
Member

Good catch. '**.thing.js' should not match, so that is a bug since ** should be treated as a single star when it's not the only thing in a path segment (according to bash).

However, the correct way to do what you want is one of the following:

const isMatch1 = picomatch('*/*.thing.js')
const isMatch2 = picomatch('**/*.thing.js')

console.log(isMatch1('somepath/test.thing.js'))      // true
console.log(isMatch2('somepath/test.thing.js'))      // true

thanks for the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants