Remove util.URLJoin and replace all callers with direct path concatenation (#36867)
`util.URLJoin` was deprecated with unclear semantics (path normalization via `url.Parse`/`ResolveReference` that surprised callers). This removes it entirely and replaces all usages with straightforward `"/"` string concatenation. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
This commit is contained in:
@@ -11,39 +11,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestURLJoin(t *testing.T) {
|
||||
type test struct {
|
||||
Expected string
|
||||
Base string
|
||||
Elements []string
|
||||
}
|
||||
newTest := func(expected, base string, elements ...string) test {
|
||||
return test{Expected: expected, Base: base, Elements: elements}
|
||||
}
|
||||
for _, test := range []test{
|
||||
newTest("https://try.gitea.io/a/b/c",
|
||||
"https://try.gitea.io", "a/b", "c"),
|
||||
newTest("https://try.gitea.io/a/b/c",
|
||||
"https://try.gitea.io/", "/a/b/", "/c/"),
|
||||
newTest("https://try.gitea.io/a/c",
|
||||
"https://try.gitea.io/", "/a/./b/", "../c/"),
|
||||
newTest("a/b/c",
|
||||
"a", "b/c/"),
|
||||
newTest("a/b/d",
|
||||
"a/", "b/c/", "/../d/"),
|
||||
newTest("https://try.gitea.io/a/b/c#d",
|
||||
"https://try.gitea.io", "a/b", "c#d"),
|
||||
newTest("/a/b/d",
|
||||
"/a/", "b/c/", "/../d/"),
|
||||
newTest("/a/b/c",
|
||||
"/a", "b/c/"),
|
||||
newTest("/a/b/c#hash",
|
||||
"/a", "b/c#hash"),
|
||||
} {
|
||||
assert.Equal(t, test.Expected, URLJoin(test.Base, test.Elements...))
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsEmptyString(t *testing.T) {
|
||||
cases := []struct {
|
||||
s string
|
||||
|
||||
Reference in New Issue
Block a user