2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-02 00:50:48 +00:00

strip off the trailing slash for the object prefix

This commit is contained in:
Christian Kemper 2016-02-14 07:16:50 -08:00
parent 48f85fbb09
commit 74608531c7
2 changed files with 23 additions and 1 deletions

View File

@ -63,7 +63,7 @@ func ParseConfig(s string) (interface{}, error) {
}
cfg.Bucket = path[0]
if len(path) > 1 {
cfg.Prefix = path[1]
cfg.Prefix = strings.TrimRight(path[1], "/")
} else {
cfg.Prefix = defaultPrefix
}

View File

@ -21,6 +21,11 @@ var configTests = []struct {
Bucket: "bucketname",
Prefix: "prefix/directory",
}},
{"s3://eu-central-1/bucketname/prefix/directory/", Config{
Endpoint: "eu-central-1",
Bucket: "bucketname",
Prefix: "prefix/directory",
}},
{"s3:eu-central-1/foobar", Config{
Endpoint: "eu-central-1",
Bucket: "foobar",
@ -36,6 +41,11 @@ var configTests = []struct {
Bucket: "foobar",
Prefix: "prefix/directory",
}},
{"s3:eu-central-1/foobar/prefix/directory/", Config{
Endpoint: "eu-central-1",
Bucket: "foobar",
Prefix: "prefix/directory",
}},
{"s3:https://hostname:9999/foobar", Config{
Endpoint: "hostname:9999",
Bucket: "foobar",
@ -52,12 +62,24 @@ var configTests = []struct {
Prefix: "restic",
UseHTTP: true,
}},
{"s3:http://hostname:9999/foobar/", Config{
Endpoint: "hostname:9999",
Bucket: "foobar",
Prefix: "",
UseHTTP: true,
}},
{"s3:http://hostname:9999/bucket/prefix/directory", Config{
Endpoint: "hostname:9999",
Bucket: "bucket",
Prefix: "prefix/directory",
UseHTTP: true,
}},
{"s3:http://hostname:9999/bucket/prefix/directory/", Config{
Endpoint: "hostname:9999",
Bucket: "bucket",
Prefix: "prefix/directory",
UseHTTP: true,
}},
}
func TestParseConfig(t *testing.T) {