ExpandHomeDir Fix on Windows (#909)

fix: check for backslash when expanding the home directory (~ character
-> full path)
This commit is contained in:
Sylvie Crowe 2024-09-30 14:50:40 -07:00 committed by GitHub
parent f667ccce20
commit 7b56b0fb00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,7 +52,7 @@ func GetHomeDir() string {
} }
func ExpandHomeDir(pathStr string) (string, error) { func ExpandHomeDir(pathStr string) (string, error) {
if pathStr != "~" && !strings.HasPrefix(pathStr, "~/") { if pathStr != "~" && !strings.HasPrefix(pathStr, "~/") && (!strings.HasPrefix(pathStr, `~\`) || runtime.GOOS != "windows") {
return filepath.Clean(pathStr), nil return filepath.Clean(pathStr), nil
} }
homeDir := GetHomeDir() homeDir := GetHomeDir()