Skip to content

Commit

Permalink
fix: Don't rstrip slash when service_url is none
Browse files Browse the repository at this point in the history
  • Loading branch information
rmkeezer committed May 22, 2020
1 parent ea6cf85 commit 091ecde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ibm_cloud_sdk_core/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ def set_service_url(self, service_url: str) -> None:
'The service url shouldn\'t start or end with curly brackets or quotes. '
'Be sure to remove any {} and \" characters surrounding your service url'
)
self.service_url = service_url.rstrip('/') # remove trailing slash
if service_url is not None:
self.service_url = service_url.rstrip('/') # remove trailing slash
else:
self.service_url = None

def get_authenticator(self) -> Authenticator:
"""Get the authenticator currently used by the service.
Expand Down
3 changes: 3 additions & 0 deletions test/test_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ def test_trailing_slash():
data={'hello': 'world'})
assert req.get('url') == 'https://trailingSlash.com'

service.set_service_url(None)
assert service.service_url is None

service = AnyServiceV1('2018-11-20', service_url='/', authenticator=NoAuthAuthenticator())
assert service.service_url == ''
service.set_service_url('/')
Expand Down

0 comments on commit 091ecde

Please sign in to comment.