forked from TrueCloudLab/restic
internal: backend: sftp: support user@domain parsing as user
This commit is contained in:
parent
72bd467e23
commit
97e5ce4344
2 changed files with 12 additions and 3 deletions
|
@ -56,8 +56,11 @@ func ParseConfig(s string) (interface{}, error) {
|
|||
host = data[0]
|
||||
dir = data[1]
|
||||
// split user and host at the "@"
|
||||
data = strings.SplitN(host, "@", 2)
|
||||
if len(data) == 2 {
|
||||
data = strings.SplitN(host, "@", 3)
|
||||
if len(data) == 3 {
|
||||
user = data[0] + "@" + data[1]
|
||||
host = data[2]
|
||||
} else if len(data) == 2 {
|
||||
user = data[0]
|
||||
host = data[1]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package sftp
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var configTests = []struct {
|
||||
in string
|
||||
|
@ -41,6 +43,10 @@ var configTests = []struct {
|
|||
"sftp:user@host:/dir/subdir",
|
||||
Config{User: "user", Host: "host", Path: "/dir/subdir"},
|
||||
},
|
||||
{
|
||||
"sftp:user@domain@host:/dir/subdir",
|
||||
Config{User: "user@domain", Host: "host", Path: "/dir/subdir"},
|
||||
},
|
||||
{
|
||||
"sftp:host:../dir/subdir",
|
||||
Config{Host: "host", Path: "../dir/subdir"},
|
||||
|
|
Loading…
Reference in a new issue