mirror of https://github.com/zulip/zulip.git
subdomains: Refactor get_subdomain a bit.
The helper _extract_subdomain doesn't have a super meaningful interface, and this is its one callsite. So just inline it.
This commit is contained in:
parent
cc32634439
commit
66ebe9720f
|
@ -6,17 +6,13 @@ from typing import Optional, Text
|
|||
|
||||
from zerver.models import get_realm, Realm, UserProfile
|
||||
|
||||
def _extract_subdomain(request):
|
||||
# type: (HttpRequest) -> Text
|
||||
domain = request.get_host().lower()
|
||||
index = domain.find("." + settings.EXTERNAL_HOST)
|
||||
if index == -1:
|
||||
return Realm.SUBDOMAIN_FOR_ROOT_DOMAIN
|
||||
return domain[0:index]
|
||||
|
||||
def get_subdomain(request):
|
||||
# type: (HttpRequest) -> Text
|
||||
subdomain = _extract_subdomain(request)
|
||||
host = request.get_host().lower()
|
||||
index = host.find("." + settings.EXTERNAL_HOST)
|
||||
if index == -1:
|
||||
return Realm.SUBDOMAIN_FOR_ROOT_DOMAIN
|
||||
subdomain = host[0:index]
|
||||
if subdomain in settings.ROOT_SUBDOMAIN_ALIASES:
|
||||
return Realm.SUBDOMAIN_FOR_ROOT_DOMAIN
|
||||
return subdomain
|
||||
|
|
Loading…
Reference in New Issue