Skip to content

Commit

Permalink
Expect exclusively forward slash as path sep, same as node-glob
Browse files Browse the repository at this point in the history
Close: #109
  • Loading branch information
erikkemperman authored and isaacs committed Feb 15, 2022
1 parent 58b72d3 commit 9104d8d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ See:
* `man 3 fnmatch`
* `man 5 gitignore`

## Windows

**Please only use forward-slashes in glob expressions.**

Though windows uses either `/` or `\` as its path separator, only `/`
characters are used by this glob implementation. You must use
forward-slashes **only** in glob expressions. Back-slashes in patterns
will always be interpreted as escape characters, not path separators.

Note that `\` or `/` _will_ be interpreted as path separators in paths on
Windows, and will match against `/` in glob expressions.

So just always use `/` in patterns.

## Minimatch Class

Create a minimatch object by instantiating the `minimatch.Minimatch` class.
Expand Down Expand Up @@ -187,12 +201,6 @@ minimatch('/a/b', '/**/d', { partial: true }) // true, might be /a/b/.../d
minimatch('/x/y/z', '/a/**/z', { partial: true }) // false, because x !== a
```

### allowWindowsEscape

Windows path separator `\` is by default converted to `/`, which
prohibits the usage of `\` as a escape character. This flag skips that
behavior and allows using the escape character.

## Comparisons to other fnmatch/glob implementations

While strict compliance with the existing standards is a worthwhile
Expand Down
5 changes: 0 additions & 5 deletions minimatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ class Minimatch {

if (!options) options = {}

// windows support: need to use /, not \
if (!options.allowWindowsEscape && path.sep !== '/') {
pattern = pattern.split(path.sep).join('/')
}

this.options = options
this.set = []
this.pattern = pattern
Expand Down

0 comments on commit 9104d8d

Please sign in to comment.