Skip to content

Commit

Permalink
Set public_url() protocol based on use_https
Browse files Browse the repository at this point in the history
If use_https is true, prefix public URLs with https. Otherwise use
http as before.
  • Loading branch information
junousi committed Feb 28, 2019
1 parent 9cb3db4 commit 27d7806
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions S3/S3Uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ def is_dns_compatible(self):
return check_bucket_name_dns_support(Config.Config().host_bucket, self._bucket)

def public_url(self):
public_url_protocol = "http"
if Config.Config().use_https:
public_url_protocol = "https"
if self.is_dns_compatible():
return "http://%s.%s/%s" % (self._bucket, Config.Config().host_base, self._object)
return "%s://%s.%s/%s" % (public_url_protocol, self._bucket, Config.Config().host_base, self._object)
else:
return "http://%s/%s/%s" % (Config.Config().host_base, self._bucket, self._object)
return "%s://%s/%s/%s" % (public_url_protocol, Config.Config().host_base, self._bucket, self._object)

def host_name(self):
if self.is_dns_compatible():
Expand Down

0 comments on commit 27d7806

Please sign in to comment.