Skip to content

Commit b9848a5

Browse files
committed
Allow empty paths
1 parent a1177b8 commit b9848a5

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

paths.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ type Path struct {
4949
// then nil is returned.
5050
func New(path ...string) *Path {
5151
if len(path) == 0 {
52-
return nil
53-
}
54-
if len(path) == 1 && path[0] == "" {
55-
return nil
52+
return New("")
5653
}
5754
res := &Path{path: path[0]}
5855
if len(path) > 1 {

paths_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ func TestPathNew(t *testing.T) {
4444
require.Equal(t, filepath.Join("path", "path"), test2.String())
4545

4646
test3 := New()
47-
require.Nil(t, test3)
47+
require.Equal(t, "", test3.String())
4848

4949
test4 := New("")
50-
require.Nil(t, test4)
50+
require.Equal(t, "", test4.String())
5151
}
5252

5353
func TestPath(t *testing.T) {

0 commit comments

Comments
 (0)