From 24b7514fe01942693b376dbc3c2fdbd3ac7fc7cd Mon Sep 17 00:00:00 2001 From: Christian Kemper Date: Sun, 14 Feb 2016 09:45:58 -0800 Subject: [PATCH] cleaner sharing of s3: and s3:// configuration --- backend/s3/config.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/backend/s3/config.go b/backend/s3/config.go index 985db0aad..e2bccd801 100644 --- a/backend/s3/config.go +++ b/backend/s3/config.go @@ -39,18 +39,17 @@ func ParseConfig(s string) (interface{}, error) { path := strings.SplitN(url.Path[1:], "/", 2) return createConfig(url.Host, path, url.Scheme == "http") + case strings.HasPrefix(s, "s3://"): + s = s[5:] case strings.HasPrefix(s, "s3:"): - // use the first entry of the path as the endpoint and the - // remainder as bucket name and prefix s = s[3:] - if strings.HasPrefix(s, "//") { - s = s[2:] - } - path := strings.SplitN(s, "/", 3) - return createConfig(path[0], path[1:], false) default: return nil, errors.New("s3: invalid format") } + // use the first entry of the path as the endpoint and the + // remainder as bucket name and prefix + path := strings.SplitN(s, "/", 3) + return createConfig(path[0], path[1:], false) } func createConfig(endpoint string, path []string, useHTTP bool) (interface{}, error) {