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

Inconsistent behavior around patterns with a trailing / #458

Open
SuperchupuDev opened this issue Sep 25, 2024 · 0 comments
Open

Inconsistent behavior around patterns with a trailing / #458

SuperchupuDev opened this issue Sep 25, 2024 · 0 comments

Comments

@SuperchupuDev
Copy link

SuperchupuDev commented Sep 25, 2024

Environment

  • OS Version: Windows 10 22H2
  • Node.js Version: 22.8.0

Actual behavior

it looks like fast-glob has inconsistent behavior around trailing / in patterns and the behavior of only returning directories is only present if the pattern is dynamic (and otherwise fast-glob matches files too). in both glob and fs.glob, only directories are returned if the pattern ends with a /

Expected behavior

fast-glob only returns directories if the pattern ends with / even if it's a dynamic pattern

Steps to reproduce

  1. use a dynamic pattern that ends with / (it only returns directories)
  2. use a static pattern that refers to a file and ends with / (it matches the file)

Code sample

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
});
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

1 participant