From 30416c860b7138c53044792c00a2c6d5615605e3 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 15 Nov 2013 10:44:09 -0500 Subject: [PATCH] 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) --- zulip/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zulip/__init__.py b/zulip/__init__.py index aee2d53..6abb93e 100644 --- a/zulip/__init__.py +++ b/zulip/__init__.py @@ -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