Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'allowWindowsEscape' option #103

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ Suppress the behavior of treating a leading `!` character as negation.
Returns from negate expressions the same as if they were not negated.
(Ie, true on a hit, false on a miss.)

### 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

Expand Down
4 changes: 2 additions & 2 deletions minimatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function Minimatch (pattern, options) {
pattern = pattern.trim()

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

Expand Down Expand Up @@ -709,7 +709,7 @@ function match (f, partial) {
var options = this.options

// windows: need to use /, not \
if (path.sep !== '/') {
if (!options.allowWindowsEscape && path.sep !== '/') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be done. Even if we aren't forcing \ to be a path separator in the pattern, we still need to make the path we're matching use / characters.

f = f.split(path.sep).join('/')
}

Expand Down