Skip to content

Commit 09a193c

Browse files
committed
fix: Revert stripping request URL trailing slashes
1 parent 5da47e2 commit 09a193c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

ibm_cloud_sdk_core/base_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def prepare_request(self,
272272
# validate the service url is set
273273
if not self.service_url:
274274
raise ValueError('The service_url is required')
275-
request['url'] = self.service_url + url.rstrip('/') # strip trailing slash
275+
request['url'] = self.service_url + url
276276

277277
headers = remove_null_values(headers) if headers else {}
278278
headers = cleanup_values(headers)

test/test_base_service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ def test_json():
518518
req = service.prepare_request('POST', url='', headers={'X-opt-out': True}, data={'hello': 'world'})
519519
assert req.get('data') == "{\"hello\": \"world\"}"
520520

521+
# For v2.x this test expects to see trailing slashes, this should be changed in v3.x
521522
def test_trailing_slash():
522523
service = AnyServiceV1('2018-11-20', service_url='https://trailingSlash.com/', authenticator=NoAuthAuthenticator())
523524
assert service.service_url == 'https://trailingSlash.com/'
@@ -527,7 +528,7 @@ def test_trailing_slash():
527528
url='/trailingSlashPath/',
528529
headers={'X-opt-out': True},
529530
data={'hello': 'world'})
530-
assert req.get('url') == 'https://trailingSlash.com//trailingSlashPath'
531+
assert req.get('url') == 'https://trailingSlash.com//trailingSlashPath/'
531532

532533
service = AnyServiceV1('2018-11-20', service_url='https://trailingSlash.com/', authenticator=NoAuthAuthenticator())
533534
assert service.service_url == 'https://trailingSlash.com/'
@@ -537,7 +538,7 @@ def test_trailing_slash():
537538
url='/',
538539
headers={'X-opt-out': True},
539540
data={'hello': 'world'})
540-
assert req.get('url') == 'https://trailingSlash.com/'
541+
assert req.get('url') == 'https://trailingSlash.com//'
541542

542543
service.set_service_url(None)
543544
assert service.service_url is None
@@ -550,7 +551,7 @@ def test_trailing_slash():
550551
url='/',
551552
headers={'X-opt-out': True},
552553
data={'hello': 'world'})
553-
assert req.get('url') == '/'
554+
assert req.get('url') == '//'
554555

555556
def test_service_url_not_set():
556557
service = BaseService(service_url='', authenticator=NoAuthAuthenticator())

0 commit comments

Comments
 (0)