Skip to content

Commit

Permalink
internal/flags: use filepath.Clean instead of path.Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden committed Jan 2, 2023
1 parent 577db2e commit 5ef2e44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"math/big"
"os"
"os/user"
"path"
"path/filepath"
"strings"

"github.com/ethereum/go-ethereum/common/math"
Expand Down Expand Up @@ -319,7 +319,7 @@ func expandPath(p string) string {
p = home + p[1:]
}
}
return path.Clean(os.ExpandEnv(p))
return filepath.Clean(os.ExpandEnv(p))
}

func HomeDir() string {
Expand Down
12 changes: 7 additions & 5 deletions internal/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import (
func TestPathExpansion(t *testing.T) {
user, _ := user.Current()
tests := map[string]string{
"/home/someuser/tmp": "/home/someuser/tmp",
"~/tmp": user.HomeDir + "/tmp",
"~thisOtherUser/b/": "~thisOtherUser/b",
"$DDDXXX/a/b": "/tmp/a/b",
"/a/b/": "/a/b",
"/home/someuser/tmp": "/home/someuser/tmp",
"~/tmp": user.HomeDir + "/tmp",
"~thisOtherUser/b/": "~thisOtherUser/b",
"$DDDXXX/a/b": "/tmp/a/b",
"/a/b/": "/a/b",
"C:\\Documents\\Newsletters\\": "C:\\Documents\\Newsletters\\",
"C:\\": "C:\\",
}
os.Setenv("DDDXXX", "/tmp")
for test, expected := range tests {
Expand Down

0 comments on commit 5ef2e44

Please sign in to comment.