Skip to content

Commit

Permalink
context: abs - fix ~
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Aug 15, 2024
1 parent affaa65 commit d1838fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ func expandHome(s string) (string, error) {
return "", err
}
home = filepath.ToSlash(home)
s = strings.Replace(s, "~/", home+"/", 1)
switch s {
case "~":
s = home
default:
s = strings.Replace(s, "~/", home+"/", 1)
}
}
return s, nil
}
Expand Down
2 changes: 2 additions & 0 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func TestContextAbs(t *testing.T) {
"", "./", wd("")+"/",
"", "", wd("")+"/",
"", ".", wd("")+"/"+".",
"", "~", home(""),
"", "~/file", home("file"),
)

for index := 0; index < len(tests); index += 3 {
Expand Down

0 comments on commit d1838fe

Please sign in to comment.