mirror of
https://github.com/restic/restic.git
synced 2025-10-09 16:41:09 +00:00
backend, options: Prefer strings.Cut to SplitN
Also realigned the various "split into host🪣prefix"
implementations.
This commit is contained in:

committed by
Michael Eischer

parent
60aa87bbab
commit
65612d797c
@@ -60,14 +60,13 @@ func ParseConfig(s string) (interface{}, error) {
|
||||
// "user@host:path" in s
|
||||
s = s[5:]
|
||||
// split user@host and path at the colon
|
||||
data := strings.SplitN(s, ":", 2)
|
||||
if len(data) < 2 {
|
||||
var colon bool
|
||||
host, dir, colon = strings.Cut(s, ":")
|
||||
if !colon {
|
||||
return nil, errors.New("sftp: invalid format, hostname or path not found")
|
||||
}
|
||||
host = data[0]
|
||||
dir = data[1]
|
||||
// split user and host at the "@"
|
||||
data = strings.SplitN(host, "@", 3)
|
||||
data := strings.SplitN(host, "@", 3)
|
||||
if len(data) == 3 {
|
||||
user = data[0] + "@" + data[1]
|
||||
host = data[2]
|
||||
|
Reference in New Issue
Block a user