Skip to content

Commit

Permalink
Merge pull request #500 from restic/fix-499
Browse files Browse the repository at this point in the history
Fix exclude filters with trailing slash
  • Loading branch information
fd0 committed Apr 18, 2016
2 parents 1eb896a + 6fe2554 commit 0390196
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/restic/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func Match(pattern, str string) (matched bool, err error) {
return true, nil
}

pattern = filepath.Clean(pattern)

if str == "" {
return false, ErrBadString
}
Expand Down
13 changes: 13 additions & 0 deletions src/restic/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ var matchTests = []struct {
{"tesT.*", "/foo/bar/test.go", false},
{"bar/*", "/foo/bar/baz", true},
{"bar", "/foo/bar", true},
{"/foo/bar", "/foo/bar", true},
{"/foo/bar/", "/foo/bar", true},
{"/foo/bar", "/foo/baz", false},
{"/foo/bar", "/foo/baz/", false},
{"/foo///bar", "/foo/bar", true},
{"/foo/../bar", "/foo/bar", false},
{"/foo/../bar", "/bar", true},
{"/foo", "/foo/baz", true},
{"/foo/", "/foo/baz", true},
{"/foo/*", "/foo", false},
{"/foo/*", "/foo/baz", true},
{"bar", "/foo/bar/baz", true},
{"bar", "/foo/bar/test.go", true},
{"/foo/*test.*", "/foo/bar/test.go", false},
Expand Down Expand Up @@ -74,6 +85,8 @@ var matchTests = []struct {
{"user/**/important*", "/home/user/work/x/y/hidden/x", false},
{"user/**/hidden*/**/c", "/home/user/work/x/y/hidden/z/a/b/c", true},
{"c:/foo/*test.*", "c:/foo/bar/test.go", false},
{"c:/foo", "c:/foo/bar", true},
{"c:/foo/", "c:/foo/bar", true},
{"c:/foo/*/test.*", "c:/foo/bar/test.go", true},
{"c:/foo/*/bar/test.*", "c:/foo/bar/test.go", false},
}
Expand Down

0 comments on commit 0390196

Please sign in to comment.