diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:01:11 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:02:09 +0200 |
commit | 363723fc84f7b8477592e0105aeb331ec9a017af (patch) | |
tree | 29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/anymatch/index.js | |
parent | 5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff) |
node_modules
Diffstat (limited to 'node_modules/anymatch/index.js')
-rw-r--r-- | node_modules/anymatch/index.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/node_modules/anymatch/index.js b/node_modules/anymatch/index.js index fd70ba07e..e41161850 100644 --- a/node_modules/anymatch/index.js +++ b/node_modules/anymatch/index.js @@ -1,8 +1,9 @@ 'use strict'; -var arrify = require('arrify'); var micromatch = require('micromatch'); -var path = require('path'); +var normalize = require('normalize-path'); +var path = require('path'); // required for tests. +var arrify = function(a) { return a == null ? [] : (Array.isArray(a) ? a : [a]); }; var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) { criteria = arrify(criteria); @@ -15,12 +16,12 @@ 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)) { + switch (Object.prototype.toString.call(criterion)) { case '[object String]': result = string === criterion || altString && altString === criterion; result = result || micromatch.isMatch(string, criterion); @@ -30,6 +31,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; @@ -53,8 +55,9 @@ var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) { }, []); if (!negGlobs.length || !micromatch.any(string, negGlobs)) { if (path.sep === '\\' && typeof string === 'string') { - altString = string.split('\\').join('/'); + altString = normalize(string); altString = altString === string ? null : altString; + if (altString) altValue = [altString].concat(value.slice(1)); } matched = crit.slice(startIndex, endIndex).some(testCriteria); } |