(f, partial)
| 31999 | |
| 32000 | Minimatch.prototype.match = match |
| 32001 | function match (f, partial) { |
| 32002 | this.debug('match', f, this.pattern) |
| 32003 | // short-circuit in the case of busted things. |
| 32004 | // comments, etc. |
| 32005 | if (this.comment) return false |
| 32006 | if (this.empty) return f === '' |
| 32007 | |
| 32008 | if (f === '/' && partial) return true |
| 32009 | |
| 32010 | var options = this.options |
| 32011 | |
| 32012 | // windows: need to use /, not \ |
| 32013 | if (path.sep !== '/') { |
| 32014 | f = f.split(path.sep).join('/') |
| 32015 | } |
| 32016 | |
| 32017 | // treat the test path as a set of pathparts. |
| 32018 | f = f.split(slashSplit) |
| 32019 | this.debug(this.pattern, 'split', f) |
| 32020 | |
| 32021 | // just ONE of the pattern sets in this.set needs to match |
| 32022 | // in order for it to be valid. If negating, then just one |
| 32023 | // match means that we have failed. |
| 32024 | // Either way, return on the first hit. |
| 32025 | |
| 32026 | var set = this.set |
| 32027 | this.debug(this.pattern, 'set', set) |
| 32028 | |
| 32029 | // Find the basename of the path by looking for the last non-empty segment |
| 32030 | var filename |
| 32031 | var i |
| 32032 | for (i = f.length - 1; i >= 0; i--) { |
| 32033 | filename = f[i] |
| 32034 | if (filename) break |
| 32035 | } |
| 32036 | |
| 32037 | for (i = 0; i < set.length; i++) { |
| 32038 | var pattern = set[i] |
| 32039 | var file = f |
| 32040 | if (options.matchBase && pattern.length === 1) { |
| 32041 | file = [filename] |
| 32042 | } |
| 32043 | var hit = this.matchOne(file, pattern, partial) |
| 32044 | if (hit) { |
| 32045 | if (options.flipNegate) return true |
| 32046 | return !this.negate |
| 32047 | } |
| 32048 | } |
| 32049 | |
| 32050 | // didn't get any hits. this is success if it's a negative |
| 32051 | // pattern, failure otherwise. |
| 32052 | if (options.flipNegate) return false |
| 32053 | return this.negate |
| 32054 | } |
| 32055 | |
| 32056 | // set partial to true to test if, for example, |
| 32057 | // "/a/b" matches the start of "/*/b/*/d" |
no test coverage detected