talira

minimatch

Glob matching for JavaScript, without regular expressions

open sourceBlueOak-1.0.0free

minimatch is a glob matching library for JavaScript and the matcher behind glob (node-glob). It splits a glob on / and tests each path segment with a non-recursive matcher instead of compiling the pattern to a regular expression, so from version 11 it isn't open to ReDoS from patterns like a*a*a*a*a, where earlier versions and most other JavaScript glob matchers are. Its maintainers still warn against matching untrusted patterns in a system without limits. It's by Isaac Z. Schlueter.

Problems it solves

  • match file paths against glob patterns in Node.js
  • test whether a path matches a glob without ReDoS risk
  • filter a list of filenames with wildcards in JavaScript

Features

  • glob pattern matching for paths
  • non-recursive matching without regular expressions
  • ReDoS-resistant from v11
  • used by node-glob

Limitations

  • Any pattern matching on arbitrary user input can still hit slow edge cases: its maintainers warn against accepting untrusted patterns without limits.1

Alternatives

The same job

These do what minimatch does.

  1. fast-glob Very fast and efficient glob library for Node.js
  2. glob Match files using the patterns the shell uses
  3. globby Glob matching for Node.js with negated patterns, directory expansion and .gitignore support
  4. rimraf rm -rf for Node.js, cross-platform

Compare minimatch with the top 3