Replace ~ only if the path begins with ~

This commit is contained in:
2024-10-08 14:09:37 +02:00
parent 02106824fd
commit 41bac18525

View File

@@ -62,7 +62,7 @@ func AreSame(lhs string, rhs string) bool {
}
func ConvertHome(input string) (string, error) {
if strings.Contains(input, "~") {
if strings.HasPrefix(input, "~/") {
homedir, err := os.UserHomeDir()
if err != nil {
return input, fmt.Errorf("unable to convert ~ to user directory with error %+v", err)