Skip to content

Commit

Permalink
Add matchBase, and test
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Dec 22, 2011
1 parent 3cdf2bf commit 59da167
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions minimatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,10 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
console.error("matchOne", this.pattern, file, pattern)
}

if (options.matchBase && pattern.length === 1) {
file = path.basename(file.join("/")).split("/")
}

// console.error("matchOne", file.length, pattern.length)

for ( var fi = 0
Expand Down
4 changes: 4 additions & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ tap.test("basic tests", function (t) {
, [ "*(a|{b|c,c})", ["x(a|b|c)", "x(a|c)", "(a|b|c)", "(a|c)"]
, { noext: true } ]

// test of matchBase
, ["a?b", ["x/y/acb", "acb/"], {matchBase: true}
, ["x/y/acb", "acb/", "acb/d/e", "x/y/acb/d"] ]

].forEach(function (c) {
if (typeof c === "function") return c()
if (typeof c === "string") return t.comment(c)
Expand Down

0 comments on commit 59da167

Please sign in to comment.