Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #53 #54

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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