Skip to content

Commit

Permalink
fix: fix unit test TestJoinPath
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <zongzhe1024@163.com>
  • Loading branch information
zong-zhe committed Dec 4, 2024
1 parent 8b34ba0 commit 5d0c935
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ func JoinPath(elems ...string) string {
}
elem = strings.TrimPrefix(elem, "/")
elem = strings.TrimSuffix(elem, "/")
if i == 0 {
if i == 0 || result == "" {
result = elem
} else {
result = result + "/" + elem
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ func TestJoinPath(t *testing.T) {
assert.Equal(t, JoinPath("base", "elem"), "base/elem")
assert.Equal(t, JoinPath("base/", "elem"), "base/elem")
assert.Equal(t, JoinPath("base", "/elem"), "base/elem")
assert.Equal(t, JoinPath("", "/elem"), "/elem")
assert.Equal(t, JoinPath("", "elem"), "/elem")
assert.Equal(t, JoinPath("base/", ""), "base/")
assert.Equal(t, JoinPath("base", ""), "base/")
assert.Equal(t, JoinPath("", "elem"), "elem")
assert.Equal(t, JoinPath("", "elem"), "elem")
assert.Equal(t, JoinPath("base/", ""), "base")
assert.Equal(t, JoinPath("base", ""), "base")
}

func TestIsUrl(t *testing.T) {
Expand Down

0 comments on commit 5d0c935

Please sign in to comment.