From f8145c54f34075069f4a23cb214d871da4cd4006 Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Thu, 20 Oct 2016 15:20:09 +0900 Subject: [PATCH] Add 'allowWindowsEscape' option PR-URL: https://github.com/isaacs/minimatch/pull/103 Credit: @frandiox Close: #103 Reviewed-by: @isaacs --- README.md | 6 ++++++ minimatch.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e9bd0f4..33ede1d6 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,12 @@ 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 90eacf6a..e07c58f1 100644 --- a/minimatch.js +++ b/minimatch.js @@ -135,7 +135,7 @@ function Minimatch (pattern, options) { if (!options) options = {} // windows support: need to use /, not \ - if (path.sep !== '/') { + if (!options.allowWindowsEscape && path.sep !== '/') { pattern = pattern.split(path.sep).join('/') }