@@ -160,8 +160,9 @@ func (s *S3Bucket) Query(q dsq.Query) (dsq.Results, error) {
160160 return nil , fmt .Errorf ("s3ds: filters or orders are not supported" )
161161 }
162162
163- // S3 store a "/foo" key as "foo" so we need to trim the leading "/"
164- q .Prefix = strings .TrimPrefix (q .Prefix , "/" )
163+ // Normalize the path and strip the leading / as S3 stores values
164+ // without the leading /.
165+ prefix := ds .NewKey (q .Prefix ).String ()[1 :]
165166
166167 sent := 0
167168 queryLimit := func () int64 {
@@ -173,7 +174,7 @@ func (s *S3Bucket) Query(q dsq.Query) (dsq.Results, error) {
173174
174175 resp , err := s .S3 .ListObjectsV2 (& s3.ListObjectsV2Input {
175176 Bucket : aws .String (s .Bucket ),
176- Prefix : aws .String (s .s3Path (q . Prefix )),
177+ Prefix : aws .String (s .s3Path (prefix )),
177178 MaxKeys : aws .Int64 (queryLimit ()),
178179 })
179180 if err != nil {
@@ -195,7 +196,7 @@ func (s *S3Bucket) Query(q dsq.Query) (dsq.Results, error) {
195196
196197 resp , err = s .S3 .ListObjectsV2 (& s3.ListObjectsV2Input {
197198 Bucket : aws .String (s .Bucket ),
198- Prefix : aws .String (s .s3Path (q . Prefix )),
199+ Prefix : aws .String (s .s3Path (prefix )),
199200 Delimiter : aws .String ("/" ),
200201 MaxKeys : aws .Int64 (queryLimit ()),
201202 ContinuationToken : resp .NextContinuationToken ,
0 commit comments