Skip to content

Inconsistent behavior around patterns with a trailing / #458

@SuperchupuDev

Description

@SuperchupuDev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions