mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 22:27:35 +00:00
backend/rest: Ensure base URL ends with slash
This makes it easier for rclone.
This commit is contained in:
parent
4d5c7a8749
commit
17312d3a98
@ -681,7 +681,7 @@ return JSON. Any different value for this header means API version 1.
|
|||||||
|
|
||||||
The placeholder ``{path}`` in this document is a path to the repository, so
|
The placeholder ``{path}`` in this document is a path to the repository, so
|
||||||
that multiple different repositories can be accessed. The default path is
|
that multiple different repositories can be accessed. The default path is
|
||||||
``/``.
|
``/``. The path must end with a slash.
|
||||||
|
|
||||||
POST {path}?create=true
|
POST {path}?create=true
|
||||||
=======================
|
=======================
|
||||||
|
@ -32,6 +32,10 @@ func ParseConfig(s string) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s = s[5:]
|
s = s[5:]
|
||||||
|
if !strings.HasSuffix(s, "/") {
|
||||||
|
s += "/"
|
||||||
|
}
|
||||||
|
|
||||||
u, err := url.Parse(s)
|
u, err := url.Parse(s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -19,24 +19,34 @@ var configTests = []struct {
|
|||||||
s string
|
s string
|
||||||
cfg Config
|
cfg Config
|
||||||
}{
|
}{
|
||||||
{"rest:http://localhost:1234", Config{
|
{
|
||||||
URL: parseURL("http://localhost:1234"),
|
s: "rest:http://localhost:1234",
|
||||||
Connections: 5,
|
cfg: Config{
|
||||||
}},
|
URL: parseURL("http://localhost:1234/"),
|
||||||
|
Connections: 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "rest:http://localhost:1234/",
|
||||||
|
cfg: Config{
|
||||||
|
URL: parseURL("http://localhost:1234/"),
|
||||||
|
Connections: 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseConfig(t *testing.T) {
|
func TestParseConfig(t *testing.T) {
|
||||||
for i, test := range configTests {
|
for _, test := range configTests {
|
||||||
cfg, err := ParseConfig(test.s)
|
t.Run("", func(t *testing.T) {
|
||||||
if err != nil {
|
cfg, err := ParseConfig(test.s)
|
||||||
t.Errorf("test %d:%s failed: %v", i, test.s, err)
|
if err != nil {
|
||||||
continue
|
t.Fatalf("%s failed: %v", test.s, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(cfg, test.cfg) {
|
if !reflect.DeepEqual(cfg, test.cfg) {
|
||||||
t.Errorf("test %d:\ninput:\n %s\n wrong config, want:\n %v\ngot:\n %v",
|
t.Fatalf("\ninput: %s\n wrong config, want:\n %v\ngot:\n %v",
|
||||||
i, test.s, test.cfg, cfg)
|
test.s, test.cfg, cfg)
|
||||||
continue
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user