Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved the logic to remove www from Site.domain into current_site_doma…

…in to fix issues reversing URLs when Site.domain has a www.
  • Loading branch information...
commit 0a93c32c7388a7ef75f90068cb8a2feedbf1f80d 1 parent f4eeb01
@cmsimike cmsimike authored
Showing with 8 additions and 6 deletions.
  1. +0 −5 subdomains/middleware.py
  2. +8 −1 subdomains/utils.py
View
5 subdomains/middleware.py
@@ -32,11 +32,6 @@ def process_request(self, request):
domain, host = map(lower,
(self.get_domain_for_request(request), request.get_host()))
- prefix = 'www.'
- if getattr(settings, 'REMOVE_WWW_FROM_DOMAIN', False) \
- and domain.startswith(prefix):
- domain = domain.replace(prefix, '', 1)
-
pattern = r'^(?:(?P<subdomain>.*?)\.)?%s(?::.*)?$' % re.escape(domain)
matches = re.match(pattern, host)
View
9 subdomains/utils.py
@@ -7,7 +7,14 @@
def current_site_domain():
- return Site.objects.get_current().domain
+ domain = Site.objects.get_current().domain
+
+ prefix = 'www.'
+ if getattr(settings, 'REMOVE_WWW_FROM_DOMAIN', False) \
+ and domain.startswith(prefix):
+ domain = domain.replace(prefix, '', 1)
+
+ return domain
get_domain = current_site_domain
Please sign in to comment.
Something went wrong with that request. Please try again.