move base_url check in constructor
@@ -35,7 +35,7 @@ class Client():
self._headers = headers
self._default_kwargs = kwargs
- self._base_url = config['url']
+ self._base_url = config['url'][:-1] if config['url'].endswith('/') else config['url']
def _request(self, request_name, url, **request_kwargs):
"""Base request helper."""
@@ -82,17 +82,12 @@ class Client():
return r
- def _get_base_url(self):
- if self._base_url.endswith('/'):
- return self._base_url[:-1]
- return self._base_url
-
def request(self, request_name, asset_name, path=None, json_response=True,
**request_kwargs):
"""Base request."""
path = path or ''
- url = f"{self._get_base_url()}/{assets.to_server_name(asset_name)}/{path}"
+ url = f"{self._base_url}/{assets.to_server_name(asset_name)}/{path}"
if not url.endswith("/"):
url = url + "/" # server requires a suffix /
