From 177ccb0cb751b4ef7fd2f5e7828118ef8cf2d313 Mon Sep 17 00:00:00 2001 From: Dong Date: Tue, 27 Jul 2021 22:49:01 -0700 Subject: [PATCH] Fix virtual hosted style s3 detector --- detect_s3.go | 2 +- detect_s3_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/detect_s3.go b/detect_s3.go index 89f3c35dc..408f8a412 100644 --- a/detect_s3.go +++ b/detect_s3.go @@ -63,7 +63,7 @@ func (d *S3Detector) detectVhostStyle(region, bucket string, parts []string) (st } func (d *S3Detector) detectNewVhostStyle(region, bucket string, parts []string) (string, bool, error) { - urlStr := fmt.Sprintf("https://s3.%s.amazonaws.com/%s/%s", region, bucket, strings.Join(parts, "/")) + urlStr := fmt.Sprintf("https://%s.s3.%s.amazonaws.com/%s", bucket, region, strings.Join(parts, "/")) url, err := url.Parse(urlStr) if err != nil { return "", false, fmt.Errorf("error parsing S3 URL: %s", err) diff --git a/detect_s3_test.go b/detect_s3_test.go index 6aceafd8f..becb267af 100644 --- a/detect_s3_test.go +++ b/detect_s3_test.go @@ -37,7 +37,7 @@ func TestS3Detector(t *testing.T) { // 5 parts Virtual hosted-style { "bucket.s3.eu-west-1.amazonaws.com/foo/bar.baz", - "s3::https://s3.eu-west-1.amazonaws.com/bucket/foo/bar.baz", + "s3::https://bucket.s3.eu-west-1.amazonaws.com/foo/bar.baz", }, // Path style {