Skip to content

Commit fcc8b33

Browse files
committed
Merge remote-tracking branch 'origin/feat/api-core-universe-domain-helper' into feat/api-core-universe-domain-helper
2 parents ac1087d + b6e8b3a commit fcc8b33

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

packages/google-api-core/google/api_core/universe.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,12 @@ def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
138138
port = f":{parsed.port}" if parsed.port else ""
139139

140140
lowered_host = host.lower()
141-
if lowered_host.endswith(".sandbox.googleapis.com"):
142-
new_host = host[:-23] + ".mtls.sandbox.googleapis.com"
143-
elif lowered_host.endswith(".googleapis.com"):
144-
new_host = host[:-15] + ".mtls.googleapis.com"
141+
suffix_sandbox = ".sandbox.googleapis.com"
142+
suffix_google = ".googleapis.com"
143+
if lowered_host.endswith(suffix_sandbox):
144+
new_host = host[:-len(suffix_sandbox)] + ".mtls.sandbox.googleapis.com"
145+
elif lowered_host.endswith(suffix_google):
146+
new_host = host[:-len(suffix_google)] + ".mtls.googleapis.com"
145147
else:
146148
return api_endpoint
147149

0 commit comments

Comments
 (0)