From 9104d8d175bdd8843338103be1401f80774d2a10 Mon Sep 17 00:00:00 2001 From: Erik Kemperman Date: Mon, 8 May 2017 15:53:16 +0200 Subject: [PATCH] Expect exclusively forward slash as path sep, same as node-glob Close: #109 --- README.md | 20 ++++++++++++++------ minimatch.js | 5 ----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 33ede1d6..8c00cb02 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 diff --git a/minimatch.js b/minimatch.js index 4f981207..0ced35ef 100644 --- a/minimatch.js +++ b/minimatch.js @@ -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