From 81de708df2888ad3cb372dddcdd7cf450656a2d7 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 18 Nov 2025 23:18:07 -0800 Subject: [PATCH] Update weed/s3api/s3api_object_handlers_list.go Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- weed/s3api/s3api_object_handlers_list.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weed/s3api/s3api_object_handlers_list.go b/weed/s3api/s3api_object_handlers_list.go index ce8144b75..3edbc9522 100644 --- a/weed/s3api/s3api_object_handlers_list.go +++ b/weed/s3api/s3api_object_handlers_list.go @@ -356,9 +356,9 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m CommonPrefixes: commonPrefixes, } // Sort CommonPrefixes to match AWS S3 behavior - // AWS S3 treats the delimiter character as having lower priority than other characters - // For example with delimiter '/', 'foo/' comes before 'foo+1/' even though '+' (ASCII 43) < '/' (ASCII 47) - // Sorting happens on unencoded (raw) values for correct lexicographic order + // AWS S3 treats the delimiter character specially for sorting common prefixes. + // For example, with delimiter '/', 'foo/' should come before 'foo+1/' even though '+' (ASCII 43) < '/' (ASCII 47). + // This custom comparison ensures correct S3-compatible lexicographical ordering. sort.Slice(response.CommonPrefixes, func(i, j int) bool { return compareWithDelimiter(response.CommonPrefixes[i].Prefix, response.CommonPrefixes[j].Prefix, delimiter) })