Skip to content

Commit

Permalink
fix: align bucket bound hostname url builder consistency (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
cojenco committed Oct 5, 2022
1 parent 2b3e8f9 commit 8a24add
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion google/cloud/storage/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def _bucket_bound_hostname_url(host, scheme=None):
if url_parts.scheme and url_parts.netloc:
return host

return f"{scheme}://{host}/"
return f"{scheme}://{host}"


def _api_core_retry_to_resumable_media_retry(retry, num_retries=None):
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ def generate_signed_post_policy_v4(
if virtual_hosted_style:
url = f"https://{bucket_name}.storage.googleapis.com/"
elif bucket_bound_hostname:
url = _bucket_bound_hostname_url(bucket_bound_hostname, scheme)
url = f"{_bucket_bound_hostname_url(bucket_bound_hostname, scheme)}/"
else:
url = f"https://storage.googleapis.com/{bucket_name}/"

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,13 +675,13 @@ def _call_fut(self, **args):
return _bucket_bound_hostname_url(**args)

def test_full_hostname(self):
HOST = "scheme://domain.tcl/"
HOST = "scheme://domain.tcl"
self.assertEqual(self._call_fut(host=HOST), HOST)

def test_hostname_and_scheme(self):
HOST = "domain.tcl"
SCHEME = "scheme"
EXPECTED_URL = SCHEME + "://" + HOST + "/"
EXPECTED_URL = SCHEME + "://" + HOST

self.assertEqual(self._call_fut(host=HOST, scheme=SCHEME), EXPECTED_URL)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2572,7 +2572,7 @@ def test_get_signed_policy_v4_bucket_bound_hostname(self):
bucket_bound_hostname="https://bucket.bound_hostname",
credentials=_create_signing_credentials(),
)
self.assertEqual(policy["url"], "https://bucket.bound_hostname")
self.assertEqual(policy["url"], "https://bucket.bound_hostname/")

def test_get_signed_policy_v4_bucket_bound_hostname_with_scheme(self):
import datetime
Expand Down

0 comments on commit 8a24add

Please sign in to comment.