Optimize out empty path components
filepath.Join("foo", "") returns a newly allocated copy of "foo", while filepath.Join("foo") does not. Strip out any empty path components before calling filepath.Join. Test: TestValidatePath Change-Id: Ib47dbcd9d6463809acfe260dfd9af87ea280b4de
This commit is contained in:
@@ -36,6 +36,22 @@ var commonValidatePathTestCases = []strsTestCase{
|
||||
in: []string{""},
|
||||
out: "",
|
||||
},
|
||||
{
|
||||
in: []string{"", ""},
|
||||
out: "",
|
||||
},
|
||||
{
|
||||
in: []string{"a", ""},
|
||||
out: "a",
|
||||
},
|
||||
{
|
||||
in: []string{"", "a"},
|
||||
out: "a",
|
||||
},
|
||||
{
|
||||
in: []string{"", "a", ""},
|
||||
out: "a",
|
||||
},
|
||||
{
|
||||
in: []string{"a/b"},
|
||||
out: "a/b",
|
||||
|
Reference in New Issue
Block a user