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:
Tim Abbott 2013-11-15 10:44:09 -05:00
parent 8f75d55795
commit 30416c860b

View file

@ -100,13 +100,15 @@ class Client(object):
if site is not None:
if not site.startswith("http"):
site = "https://" + site
# Remove trailing "/"s from site to simplify the below logic for adding "/api"
site = site.rstrip("/")
self.base_url = site
else:
self.base_url = "https://api.zulip.com"
if self.base_url != "https://api.zulip.com" and not self.base_url.endswith("/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.client_name = client