Skip to content

Commit

Permalink
"abc**" should match "abc"; fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Aug 23, 2016
1 parent ec3b4af commit 03a2cae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doublestar.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func matchComponent(pattern, name string) (bool, error) {
}
}
if patIdx >= patternLen && nameIdx >= nameLen { return true, nil }
if nameIdx >= nameLen && pattern[patIdx:] == "*" { return true, nil }
if nameIdx >= nameLen && pattern[patIdx:] == "*" || pattern[patIdx:] == "**" { return true, nil }
return false, nil
}

2 changes: 2 additions & 0 deletions doublestar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ var matchTests = []MatchTest{
{"ab{c,d}", "abc", true, nil, true},
{"ab{c,d,*}", "abcde", true, nil, true},
{"ab{c,d}[", "abcd", false, ErrBadPattern, true},
{"abc**", "abc", true, nil, true},
{"**abc", "abc", true, nil, true},
}

func TestMatch(t *testing.T) {
Expand Down

0 comments on commit 03a2cae

Please sign in to comment.