Handle subdomains properly
This commit is contained in:
+9
-1
@@ -85,7 +85,15 @@ func (c *Client) transport() http.RoundTripper {
|
||||
func (c *Client) bucketURL(bucket string) string {
|
||||
if !c.S3ForcePathStyle {
|
||||
if IsValidBucket(bucket) && !strings.Contains(bucket, ".") {
|
||||
return fmt.Sprintf("https://%s.%s/", bucket, strings.TrimPrefix(c.endpoint(), "https://"))
|
||||
var url_ string
|
||||
if strings.Contains(c.endpoint(), "amazonaws.com") {
|
||||
url_ = fmt.Sprintf("https://%s.%s/", bucket, strings.TrimPrefix(c.endpoint(), "https://"))
|
||||
} else if strings.Contains(c.endpoint(), "localhost") || strings.Contains(bucket, "127.0.0.1") {
|
||||
url_ = fmt.Sprintf("%s/%s", c.endpoint(), bucket)
|
||||
} else {
|
||||
url_ = fmt.Sprintf("http://%s.%s/", bucket, strings.TrimPrefix(c.endpoint(), "http://"))
|
||||
}
|
||||
return url_
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s/%s", c.endpoint(), bucket)
|
||||
|
||||
Reference in New Issue
Block a user