@@ -34,6 +34,8 @@ func (d *S3Detector) detectHTTP(src string) (string, bool, error) {
34
34
return d .detectPathStyle (hostParts [0 ], parts [1 :])
35
35
} else if len (hostParts ) == 4 {
36
36
return d .detectVhostStyle (hostParts [1 ], hostParts [0 ], parts [1 :])
37
+ } else if len (hostParts ) == 5 && hostParts [1 ] == "s3" {
38
+ return d .detectNewVhostStyle (hostParts [2 ], hostParts [0 ], parts [1 :])
37
39
} else {
38
40
return "" , false , fmt .Errorf (
39
41
"URL is not a valid S3 URL" )
@@ -59,3 +61,13 @@ func (d *S3Detector) detectVhostStyle(region, bucket string, parts []string) (st
59
61
60
62
return "s3::" + url .String (), true , nil
61
63
}
64
+
65
+ func (d * S3Detector ) detectNewVhostStyle (region , bucket string , parts []string ) (string , bool , error ) {
66
+ urlStr := fmt .Sprintf ("https://s3.%s.amazonaws.com/%s/%s" , region , bucket , strings .Join (parts , "/" ))
67
+ url , err := url .Parse (urlStr )
68
+ if err != nil {
69
+ return "" , false , fmt .Errorf ("error parsing S3 URL: %s" , err )
70
+ }
71
+
72
+ return "s3::" + url .String (), true , nil
73
+ }
0 commit comments