2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-30 08:44:02 +00:00

filter: Ignore empty patterns

This commit is contained in:
Alexander Neumann 2017-04-16 20:49:20 +02:00
parent c796d84fca
commit dd65ac56ef
2 changed files with 7 additions and 1 deletions

View File

@ -100,9 +100,14 @@ func match(patterns, strs []string) (matched bool, err error) {
return false, nil
}
// List returns true if str matches one of the patterns.
// List returns true if str matches one of the patterns. Empty patterns are
// ignored.
func List(patterns []string, str string) (matched bool, err error) {
for _, pat := range patterns {
if pat == "" {
continue
}
matched, err = Match(pat, str)
if err != nil {
return false, err

View File

@ -152,6 +152,7 @@ var filterListTests = []struct {
{[]string{"?", "x"}, "/foo/bar/x", true},
{[]string{"/*/*/bar/test.*"}, "/foo/bar/test.go", false},
{[]string{"/*/*/bar/test.*", "*.go"}, "/foo/bar/test.go", true},
{[]string{"", "*.c"}, "/foo/bar/test.go", false},
}
func TestMatchList(t *testing.T) {