Skip to content

Commit

Permalink
[s3] Another delimiter + prefix fix for Contents
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZbarsky-at committed Sep 23, 2024
1 parent 7af77d5 commit 2d4a4b2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions services/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,15 @@ func (s *S3) ListObjectsV2(input ListObjectsV2Input) (*ListObjectsV2Output, *aws
continuationToken := ""
var keysToInclude []string
for _, key := range keysSorted {
if input.Delimiter != nil && strings.Contains(key, *input.Delimiter) {
continue
if input.Delimiter != nil {
keyWithoutPrefix := key
if input.Prefix != nil {
keyWithoutPrefix = key[len(*input.Prefix):]
}

if strings.Contains(keyWithoutPrefix, *input.Delimiter) {
continue
}
}

if len(keysToInclude) >= maxKeys {
Expand Down Expand Up @@ -1085,7 +1092,7 @@ func (s *S3) ListObjectsV2(input ListObjectsV2Input) (*ListObjectsV2Output, *aws
commonPrefixes := make(map[string]struct{})
for _, key := range keysSorted {
if input.Prefix != nil {
key, _ = strings.CutPrefix(key, *input.Prefix)
key = key[len(*input.Prefix):]
}
i := strings.Index(key, *input.Delimiter)
if i != -1 {
Expand Down

0 comments on commit 2d4a4b2

Please sign in to comment.