Skip to content

Commit 9104d8d

Browse files
erikkempermanisaacs
authored andcommitted
Expect exclusively forward slash as path sep, same as node-glob
Close: #109
1 parent 58b72d3 commit 9104d8d

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ See:
3535
* `man 3 fnmatch`
3636
* `man 5 gitignore`
3737

38+
## Windows
39+
40+
**Please only use forward-slashes in glob expressions.**
41+
42+
Though windows uses either `/` or `\` as its path separator, only `/`
43+
characters are used by this glob implementation. You must use
44+
forward-slashes **only** in glob expressions. Back-slashes in patterns
45+
will always be interpreted as escape characters, not path separators.
46+
47+
Note that `\` or `/` _will_ be interpreted as path separators in paths on
48+
Windows, and will match against `/` in glob expressions.
49+
50+
So just always use `/` in patterns.
51+
3852
## Minimatch Class
3953

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

190-
### allowWindowsEscape
191-
192-
Windows path separator `\` is by default converted to `/`, which
193-
prohibits the usage of `\` as a escape character. This flag skips that
194-
behavior and allows using the escape character.
195-
196204
## Comparisons to other fnmatch/glob implementations
197205

198206
While strict compliance with the existing standards is a worthwhile

minimatch.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ class Minimatch {
167167

168168
if (!options) options = {}
169169

170-
// windows support: need to use /, not \
171-
if (!options.allowWindowsEscape && path.sep !== '/') {
172-
pattern = pattern.split(path.sep).join('/')
173-
}
174-
175170
this.options = options
176171
this.set = []
177172
this.pattern = pattern

0 commit comments

Comments
 (0)