tinyglobby
tinyglobby copied to clipboard
Glob with Trailing `/` Matches Files as well as Folders
For example, packages/*/ will match a file at packages/foo.
I think expected behaviour here is to only match folders (packages/bar/).
See related downstream discussion on vitest.
interesting, does fast-glob present that behavior? can you provide a minimal repro?
I see the issue now, fast-glob (which this package aims to replace) does act that way
@kahagerman further investigating i've noticed that fast-glob (which is what vitest used before and this package aims to be a replacement of) has really inconsistent behavior around trailing / in patterns and the behavior you describe is only present if the pattern is dynamic (otherwise fast-glob matches files too!). because of this, i'm not sure if making tinyglobby inconsistent as well would be a good idea
you can test this inconsistency in fast-glob this way:
import glob from 'fast-glob';
// dynamic pattern, only returns folders so no files are matched
await glob(['*.ts/'], {
onlyFiles: false
});
// static pattern, returns files too
await glob(['index.ts/'], {
onlyFiles: false
});
Hmm. Maybe the thing to do is report it as a bug in fast-glob. If they fix it then we can remain consistent with fast-glob
reported it some days ago at mrmlnc/fast-glob#458. will probably do whatever fast-glob does as long as it's applied in a consistent way
it looks like this is easily fixable by using the strictSlashes picomatch option, but i'm not sure if it should be fixed until fast-glob becomes consistent at processing trailing slashes
EDIT: strictSlashes does something different than i thought, nevermind :P