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:
parent
c796d84fca
commit
dd65ac56ef
@ -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 New Issue
Block a user