Skip to content

Commit

Permalink
use join instead of replace for a more predictable outcome
Browse files Browse the repository at this point in the history
replace could have resulted in weird behaviour such as "some~path" becoming
incorrectly mangled
  • Loading branch information
Memet Bilgin committed Sep 14, 2024
1 parent 4c8eb53 commit 0da4763
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libvirt/uri/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (u *ConnectionURI) parseAuthMethods(target string, sshcfg *ssh_config.Confi
if strings.HasPrefix(path, "~/") {
home, err := os.UserHomeDir()
if err == nil {
path = strings.Replace(path, "~", home, 1)
path = filepath.Join(home, path[2:])
}
}
sshKey, err := os.ReadFile(path)
Expand Down

0 comments on commit 0da4763

Please sign in to comment.