Skip to content

Commit 0e6e1e1

Browse files
committed
Do not allow empty paths
This reverts commit b9848a5.
1 parent a590df6 commit 0e6e1e1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

paths.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ type Path struct {
4848
// then nil is returned.
4949
func New(path ...string) *Path {
5050
if len(path) == 0 {
51-
return New("")
51+
return nil
52+
}
53+
if len(path) == 1 && path[0] == "" {
54+
return nil
5255
}
5356
res := &Path{path: path[0]}
5457
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.Equal(t, "", test3.String())
47+
require.Nil(t, test3)
4848

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

5353
func TestPath(t *testing.T) {

0 commit comments

Comments
 (0)