Skip to content

Commit

Permalink
Fixed #2 - globstars are too permissive
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Nov 22, 2015
1 parent 4f612bd commit 78f623e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doublestar.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ func doGlob(basedir string, components, matches []string) (m []string, e error)
// if the current component is a doublestar, we'll try depth-first
for _, file := range files {
if file.IsDir() {
m = append(m, filepath.Join(basedir, file.Name()))
if lastComponent {
m = append(m, filepath.Join(basedir, file.Name()))
}
m, e = doGlob(filepath.Join(basedir, file.Name()), components[patIdx:], m)
} else if lastComponent {
// if the pattern's last component is a doublestar, we match filenames, too
Expand Down
3 changes: 3 additions & 0 deletions doublestar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ var matchTests = []MatchTest{
{"**/c", "c", true, nil, true},
{"**/c", "b/c", true, nil, true},
{"**/c", "a/b/c", true, nil, true},
{"**/c", "a/b", false, nil, true},
{"**/c", "abcd", false, nil, true},
{"**/c", "a/abc", false, nil, true},
{"a/**/b", "a/b", true, nil, true},
{"a/**/c", "a/b/c", true, nil, true},
{"a/**/d", "a/b/c/d", true, nil, true},
Expand Down
Empty file added test/a/abc
Empty file.

0 comments on commit 78f623e

Please sign in to comment.