aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/s3api_object_handlers_test.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-10-29 17:54:30 -0700
committerchrislu <chris.lu@gmail.com>2022-10-29 17:54:30 -0700
commit8b9957d4616f9c6d416552a1db9fbd83c97c64f4 (patch)
treebc69723a00309dcd7b8e2bb229105ddd503b927e /weed/s3api/s3api_object_handlers_test.go
parent0d9f2f9e7a3a4cda273ef1d057c7f2b052b985d9 (diff)
downloadseaweedfs-8b9957d4616f9c6d416552a1db9fbd83c97c64f4.tar.xz
seaweedfs-8b9957d4616f9c6d416552a1db9fbd83c97c64f4.zip
add back "/" prefix if it is missing in object
fix https://github.com/seaweedfs/seaweedfs/issues/3737
Diffstat (limited to 'weed/s3api/s3api_object_handlers_test.go')
-rw-r--r--weed/s3api/s3api_object_handlers_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/weed/s3api/s3api_object_handlers_test.go b/weed/s3api/s3api_object_handlers_test.go
index d1043451d..2bc2d9040 100644
--- a/weed/s3api/s3api_object_handlers_test.go
+++ b/weed/s3api/s3api_object_handlers_test.go
@@ -46,3 +46,37 @@ func TestRemoveDuplicateSlashes(t *testing.T) {
})
}
}
+
+func TestS3ApiServer_toFilerUrl(t *testing.T) {
+ tests := []struct {
+ name string
+ args string
+ want string
+ }{
+ {
+ "simple",
+ "/uploads/eaf10b3b-3b3a-4dcd-92a7-edf2a512276e/67b8b9bf-7cca-4cb6-9b34-22fcb4d6e27d/Bildschirmfoto 2022-09-19 um 21.38.37.png",
+ "/uploads/eaf10b3b-3b3a-4dcd-92a7-edf2a512276e/67b8b9bf-7cca-4cb6-9b34-22fcb4d6e27d/Bildschirmfoto%202022-09-19%20um%2021.38.37.png",
+ },
+ {
+ "double prefix",
+ "//uploads/t.png",
+ "/uploads/t.png",
+ },
+ {
+ "triple prefix",
+ "///uploads/t.png",
+ "/uploads/t.png",
+ },
+ {
+ "empty prefix",
+ "uploads/t.png",
+ "/uploads/t.png",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ assert.Equalf(t, tt.want, urlEscapeObject(tt.args), "clean %v", tt.args)
+ })
+ }
+}