Skip to content

Commit

Permalink
Fallback to backslash conversion on fn matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
es128 committed Oct 5, 2015
1 parent 6ac8935 commit 1ad3b73
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) {
}
startIndex = startIndex || 0;
var string = value[0];
var altString;
var altString, altValue;
var matched = false;
var matchIndex = -1;
function testCriteria (criterion, index) {
function testCriteria(criterion, index) {
var result;
switch (toString.call(criterion)) {
case '[object String]':
Expand All @@ -30,6 +30,7 @@ var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) {
break;
case '[object Function]':
result = criterion.apply(null, value);
result = result || altValue && criterion.apply(null, altValue);
break;
default:
result = false;
Expand All @@ -55,6 +56,7 @@ var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) {
if (path.sep === '\\' && typeof string === 'string') {
altString = string.split('\\').join('/');
altString = altString === string ? null : altString;
if (altString) altValue = [altString].concat(value.slice(1));
}
matched = crit.slice(startIndex, endIndex).some(testCriteria);
}
Expand Down

0 comments on commit 1ad3b73

Please sign in to comment.