fix: keep upload urls unchanged

This commit is contained in:
richjohnrambo
2026-09-16 09:56:15 +08:00
parent 1de69fcc5b
commit 68b196215f
2 changed files with 1 additions and 69 deletions
-45
View File
@@ -74,51 +74,6 @@ func TestAuthFileRequestFromSessionRequiresTenant(t *testing.T) {
}
}
func TestNormalizeUploadURL(t *testing.T) {
for _, tc := range []struct {
name string
in string
want string
}{
{
name: "public http becomes https",
in: "http://api.118im.com/v0/file/s/abc.jpg",
want: "https://api.118im.com/v0/file/s/abc.jpg",
},
{
name: "query preserved",
in: "http://cdn.example.com/a/b.png?x=1",
want: "https://cdn.example.com/a/b.png?x=1",
},
{
name: "relative unchanged",
in: "/v0/file/s/abc.jpg",
want: "/v0/file/s/abc.jpg",
},
{
name: "https unchanged",
in: "https://api.118im.com/v0/file/s/abc.jpg",
want: "https://api.118im.com/v0/file/s/abc.jpg",
},
{
name: "localhost unchanged",
in: "http://localhost:6060/v0/file/s/abc.jpg",
want: "http://localhost:6060/v0/file/s/abc.jpg",
},
{
name: "private ip unchanged",
in: "http://10.42.0.1/v0/file/s/abc.jpg",
want: "http://10.42.0.1/v0/file/s/abc.jpg",
},
} {
t.Run(tc.name, func(t *testing.T) {
if got := normalizeUploadURL(tc.in); got != tc.want {
t.Fatalf("normalizeUploadURL(%q)=%q, want %q", tc.in, got, tc.want)
}
})
}
}
func TestAuthFileRequestFromTokenReturnsPrincipal(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()