Skip to content

Commit

Permalink
Fix for lindenlab#53
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianFanning committed Feb 1, 2022
1 parent 95af47d commit 1450bad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ func (po PageObj) GenerateJson(w http.ResponseWriter) error {
}

func (p S3Proxy) ConstructListObjInput(r *http.Request, key string) s3.ListObjectsV2Input {
// We should only get here if the path ends in a /, however, when we make the
//call to ListObjects no / should be there
prefix := strings.TrimSuffix(key, "/")
// We need to strip the first '/' from the key to make it a valid prefix
prefix := strings.TrimPrefix(key, "/")

input := s3.ListObjectsV2Input{
Bucket: aws.String(p.Bucket),
Expand Down
6 changes: 3 additions & 3 deletions browse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestConstructListObjInput(t *testing.T) {
expected: s3.ListObjectsV2Input{
Bucket: aws.String("myBucket"),
Delimiter: aws.String("/"),
Prefix: aws.String("/mypath"),
Prefix: aws.String("mypath/"),
},
},
testCase{
Expand All @@ -39,7 +39,7 @@ func TestConstructListObjInput(t *testing.T) {
expected: s3.ListObjectsV2Input{
Bucket: aws.String("myBucket"),
Delimiter: aws.String("/"),
Prefix: aws.String("/mypath"),
Prefix: aws.String("mypath/"),
MaxKeys: aws.Int64(20),
},
},
Expand All @@ -51,7 +51,7 @@ func TestConstructListObjInput(t *testing.T) {
expected: s3.ListObjectsV2Input{
Bucket: aws.String("myBucket"),
Delimiter: aws.String("/"),
Prefix: aws.String("/mypath"),
Prefix: aws.String("mypath/"),
MaxKeys: aws.Int64(20),
ContinuationToken: aws.String("FOO"),
},
Expand Down

0 comments on commit 1450bad

Please sign in to comment.