Skip to content

Commit 5ef2e44

Browse files
internal/flags: use filepath.Clean instead of path.Clean
1 parent 577db2e commit 5ef2e44

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

internal/flags/flags.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"math/big"
2424
"os"
2525
"os/user"
26-
"path"
26+
"path/filepath"
2727
"strings"
2828

2929
"github.com/ethereum/go-ethereum/common/math"
@@ -319,7 +319,7 @@ func expandPath(p string) string {
319319
p = home + p[1:]
320320
}
321321
}
322-
return path.Clean(os.ExpandEnv(p))
322+
return filepath.Clean(os.ExpandEnv(p))
323323
}
324324

325325
func HomeDir() string {

internal/flags/flags_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ import (
2525
func TestPathExpansion(t *testing.T) {
2626
user, _ := user.Current()
2727
tests := map[string]string{
28-
"/home/someuser/tmp": "/home/someuser/tmp",
29-
"~/tmp": user.HomeDir + "/tmp",
30-
"~thisOtherUser/b/": "~thisOtherUser/b",
31-
"$DDDXXX/a/b": "/tmp/a/b",
32-
"/a/b/": "/a/b",
28+
"/home/someuser/tmp": "/home/someuser/tmp",
29+
"~/tmp": user.HomeDir + "/tmp",
30+
"~thisOtherUser/b/": "~thisOtherUser/b",
31+
"$DDDXXX/a/b": "/tmp/a/b",
32+
"/a/b/": "/a/b",
33+
"C:\\Documents\\Newsletters\\": "C:\\Documents\\Newsletters\\",
34+
"C:\\": "C:\\",
3335
}
3436
os.Setenv("DDDXXX", "/tmp")
3537
for test, expected := range tests {

0 commit comments

Comments
 (0)