api: Fix our handling of the --site option.
Tested that the following all do the same thing after this patch: --site=https://ls-dev.zulip.net --site=https://ls-dev.zulip.net/ --site=https://ls-dev.zulip.net/api --site=https://ls-dev.zulip.net/api/ (imported from commit 785c005e4b4be3621d7d330a0173023ab2c77a4d)
This commit is contained in:
parent
8f75d55795
commit
30416c860b
|
@ -100,13 +100,15 @@ class Client(object):
|
||||||
if site is not None:
|
if site is not None:
|
||||||
if not site.startswith("http"):
|
if not site.startswith("http"):
|
||||||
site = "https://" + site
|
site = "https://" + site
|
||||||
|
# Remove trailing "/"s from site to simplify the below logic for adding "/api"
|
||||||
|
site = site.rstrip("/")
|
||||||
self.base_url = site
|
self.base_url = site
|
||||||
else:
|
else:
|
||||||
self.base_url = "https://api.zulip.com"
|
self.base_url = "https://api.zulip.com"
|
||||||
|
|
||||||
if self.base_url != "https://api.zulip.com" and not self.base_url.endswith("/api"):
|
if self.base_url != "https://api.zulip.com" and not self.base_url.endswith("/api"):
|
||||||
self.base_url += "/api"
|
self.base_url += "/api"
|
||||||
if not self.base_url.endswith("/"):
|
self.base_url += "/"
|
||||||
self.base_url += "/"
|
|
||||||
self.retry_on_errors = retry_on_errors
|
self.retry_on_errors = retry_on_errors
|
||||||
self.client_name = client
|
self.client_name = client
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue