always use "restic" as the default prefix for parsing.
improved test error message to make it easier to find the problematic pattern
This commit is contained in:
parent
24b7514fe0
commit
f3f1404849
2 changed files with 13 additions and 12 deletions
|
@ -3,6 +3,7 @@ package s3
|
|||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -52,20 +53,20 @@ func ParseConfig(s string) (interface{}, error) {
|
|||
return createConfig(path[0], path[1:], false)
|
||||
}
|
||||
|
||||
func createConfig(endpoint string, path []string, useHTTP bool) (interface{}, error) {
|
||||
func createConfig(endpoint string, p []string, useHTTP bool) (interface{}, error) {
|
||||
var prefix string
|
||||
switch {
|
||||
case len(path) < 1:
|
||||
case len(p) < 1:
|
||||
return nil, errors.New("s3: invalid format, host/region or bucket name not found")
|
||||
case len(path) == 1:
|
||||
case len(p) == 1 || p[1] == "":
|
||||
prefix = defaultPrefix
|
||||
default:
|
||||
prefix = strings.TrimRight(path[1], "/")
|
||||
prefix = path.Clean(p[1])
|
||||
}
|
||||
return Config{
|
||||
Endpoint: endpoint,
|
||||
UseHTTP: useHTTP,
|
||||
Bucket: path[0],
|
||||
Bucket: p[0],
|
||||
Prefix: prefix,
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue