Skip to content

Commit 091ecde

Browse files
committed
fix: Don't rstrip slash when service_url is none
1 parent ea6cf85 commit 091ecde

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ibm_cloud_sdk_core/base_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ def set_service_url(self, service_url: str) -> None:
164164
'The service url shouldn\'t start or end with curly brackets or quotes. '
165165
'Be sure to remove any {} and \" characters surrounding your service url'
166166
)
167-
self.service_url = service_url.rstrip('/') # remove trailing slash
167+
if service_url is not None:
168+
self.service_url = service_url.rstrip('/') # remove trailing slash
169+
else:
170+
self.service_url = None
168171

169172
def get_authenticator(self) -> Authenticator:
170173
"""Get the authenticator currently used by the service.

test/test_base_service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ def test_trailing_slash():
539539
data={'hello': 'world'})
540540
assert req.get('url') == 'https://trailingSlash.com'
541541

542+
service.set_service_url(None)
543+
assert service.service_url is None
544+
542545
service = AnyServiceV1('2018-11-20', service_url='/', authenticator=NoAuthAuthenticator())
543546
assert service.service_url == ''
544547
service.set_service_url('/')

0 commit comments

Comments
 (0)