diff --git a/weed/s3api/auth_signature_v4.go b/weed/s3api/auth_signature_v4.go index c52cb2dac..cf8860e9a 100644 --- a/weed/s3api/auth_signature_v4.go +++ b/weed/s3api/auth_signature_v4.go @@ -194,6 +194,8 @@ func buildPathWithForwardedPrefix(forwardedPrefix, urlPath string) string { var joined string if strings.HasSuffix(forwardedPrefix, "/") && strings.HasPrefix(urlPath, "/") { joined = forwardedPrefix + urlPath[1:] + } else if urlPath == "" { + joined = forwardedPrefix } else if !strings.HasSuffix(forwardedPrefix, "/") && !strings.HasPrefix(urlPath, "/") { joined = forwardedPrefix + "/" + urlPath } else { diff --git a/weed/s3api/auth_signature_v4_test.go b/weed/s3api/auth_signature_v4_test.go index 0bc704faf..a5f66e558 100644 --- a/weed/s3api/auth_signature_v4_test.go +++ b/weed/s3api/auth_signature_v4_test.go @@ -139,6 +139,12 @@ func TestBuildPathWithForwardedPrefix(t *testing.T) { urlPath: "bucket/obj", expected: "/storage/bucket/obj", }, + { + name: "empty urlPath with prefix", + forwardedPrefix: "/s3", + urlPath: "", + expected: "/s3", + }, } for _, tt := range tests {