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

Trailing slash discrepancy with micromatch #20

Open
sbellone opened this issue Apr 16, 2019 · 2 comments
Open

Trailing slash discrepancy with micromatch #20

sbellone opened this issue Apr 16, 2019 · 2 comments

Comments

@sbellone
Copy link

Please describe the minimum necessary steps to reproduce this issue:

const micromatch = require('micromatch'); // version must be >= 4.0.1
console.log(micromatch(['/test/t/'], ['**/t/']));
// [ '/test/t/' ]
console.log(micromatch(['/test/t/'], ['**/t']));
// []

const nm = require('nanomatch');
console.log(nm(['/test/t/'], ['**/t/']));
// [ '/test/t/' ]
console.log(nm(['/test/t/'], ['**/t']));
// [ '/test/t/' ]

What is happening:

micromatch takes into account the trailing slash and do an exact match
nanomatch doesn't take it into account and match even without trailing slash in the pattern

What should be happening instead?

Both libraries should be aligned on this behaviour. From this previous issue on micromatch about trailing slashes, I believe we will want the fix to be done here in nanomatch.

Additional info

As micromatch switched from nanomatch to picomatch in v4.x (during this refactor), micromatch's behaviour has actually changed between v3.1.10 and v4.0.1. It was previously behaving like nanomatch.
Again, after reading the discussion about the trailing slashes linked above, I believe we want to keep its new behaviour, so an additional unit test could be added in micromatch to be sure to stay consistent in the future.

@jonschlinkert
Copy link
Member

Both libraries should be aligned on this behaviour

Why?

@sbellone
Copy link
Author

Oh, I assumed that because in the description it states to be "Similar to micromatch", and because they have been aligned until last week (as micromatch was depending on it, I imagine).

Also it's a matter of having consistent behaviours inside the lib itself actually. If I take an example similar to the one from the linked discussion, I get this behaviour:

const nm = require('nanomatch');
console.log(nm(['t/'], ['t/']));
// [ 't/' ]
console.log(nm(['t/'], ['t']));
// []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants