diff --git a/cmd/restic/cmd_dump.go b/cmd/restic/cmd_dump.go index 4763ec55b..b8bfb1fc1 100644 --- a/cmd/restic/cmd_dump.go +++ b/cmd/restic/cmd_dump.go @@ -59,7 +59,7 @@ func splitPath(p string) []string { if d == "" || d == "/" { return []string{f} } - s := splitPath(path.Clean(path.Join("/", d))) + s := splitPath(path.Join("/", d)) return append(s, f) } diff --git a/cmd/restic/cmd_dump_test.go b/cmd/restic/cmd_dump_test.go new file mode 100644 index 000000000..aa43117ee --- /dev/null +++ b/cmd/restic/cmd_dump_test.go @@ -0,0 +1,27 @@ +package main + +import ( + "testing" + + rtest "github.com/restic/restic/internal/test" +) + +func TestDumpSplitPath(t *testing.T) { + testPaths := []struct { + path string + result []string + }{ + {"", []string{""}}, + {"test", []string{"test"}}, + {"test/dir", []string{"test", "dir"}}, + {"test/dir/sub", []string{"test", "dir", "sub"}}, + {"/", []string{""}}, + {"/test", []string{"test"}}, + {"/test/dir", []string{"test", "dir"}}, + {"/test/dir/sub", []string{"test", "dir", "sub"}}, + } + for _, path := range testPaths { + parts := splitPath(path.path) + rtest.Equals(t, path.result, parts) + } +}