Backslashes not supported as path separators #7

joewhite opened this Issue Apr 11, 2012 · 2 comments

2 participants


If I use minimatch (or glob) with forward slashes in my pattern, everything works as expected. But if I use backslashes as path separators in my pattern, minimatch always returns false -- it never matches anything. This means I can't use path.join to build my pattern string (even though it's an obvious choice), because path.join uses backslashes on Windows.

minimatch should work correctly with patterns that use the current platform's path separator. (It'd be even better if it always accepted either kind of path separator, regardless of the current platform.)


mm = require('minimatch');

// Simple match. Returns true, as expected.
mm('foo/bar/baz', 'foo/**/baz')

// Same match, but now using path.join.
// Expected: Should return true.
// Actual: returns false (on Windows).
path = require('path');
mm('foo/bar/baz', path.join('foo', '**', 'baz'))

// Equivalent to the previous example.
// Should return true, but instead returns false.
mm('foo/bar/baz', 'foo\\**\\baz')

Fixing this would probably just be a matter of making minimatch normalize the test string to use forward slashes instead of backslashes.


Yeah, on Windows, it should probably just normalize slashes in the pattern in the Minimatch constructor, and the test string in Minimatch.prototype.match. Since glob just uses a Minimatch object, it probably doesn't require any changes.

@mde mde pushed a commit to mde/minimatch that referenced this issue Sep 24, 2012
mde Issue #7, backslash path-separators on Windows 42c78e9
@isaacs isaacs added a commit that referenced this issue Oct 5, 2012
mde Issue #7, backslash path-separators on Windows b6f01f5


@isaacs isaacs closed this Oct 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment