From 22e51107897deaf3eab38d4e72af6da1fd121cfc Mon Sep 17 00:00:00 2001 From: Greg Price Date: Mon, 30 Oct 2017 14:13:13 -0700 Subject: [PATCH] subdomains: Dedupe out the last copy of Realm.host_for_subdomain. This makes the affected code somewhat easier to read, and paves the way for changing this logic to add support for alias domains. --- zerver/views/integrations.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/zerver/views/integrations.py b/zerver/views/integrations.py index eb6a8c2935..9532f0a398 100644 --- a/zerver/views/integrations.py +++ b/zerver/views/integrations.py @@ -26,16 +26,13 @@ def add_api_uri_context(context, request): else: display_subdomain = 'yourZulipDomain' html_settings_links = False - if display_subdomain != Realm.SUBDOMAIN_FOR_ROOT_DOMAIN: - api_url_scheme_relative = '%s.%s/api' % (display_subdomain, - settings.EXTERNAL_HOST) - else: - api_url_scheme_relative = settings.EXTERNAL_HOST + "/api" - api_url = '%s%s' % (settings.EXTERNAL_URI_SCHEME, api_url_scheme_relative) + display_host = Realm.host_for_subdomain(display_subdomain) + api_url_scheme_relative = display_host + "/api" + api_url = settings.EXTERNAL_URI_SCHEME + api_url_scheme_relative - context['api_url_scheme_relative'] = api_url_scheme_relative context['api_url'] = api_url + context['api_url_scheme_relative'] = api_url_scheme_relative context["html_settings_links"] = html_settings_links class ApiURLView(TemplateView):