forked from TrueCloudLab/restic
filter: Ignore empty patterns
This commit is contained in:
parent
c796d84fca
commit
dd65ac56ef
2 changed files with 7 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue