forked from ungleich-public/dynamicweb
Avoid nested hostnames when /dev-sites/ is opened on a site address
This commit is contained in:
parent
4379e9fb89
commit
748000afd9
1 changed files with 6 additions and 0 deletions
|
|
@ -95,6 +95,12 @@ class DevSiteSwitcherMiddleware(object):
|
|||
"""A page listing every configured site as a link, on any host"""
|
||||
host, _, port = request.get_host().partition(':')
|
||||
port = ':' + port if port else ''
|
||||
# opened on a site's own address (e.g. blog.ungleich.ch.localhost):
|
||||
# drop that site's prefix so links are not nested
|
||||
for domain in self.domains():
|
||||
if host.lower().startswith(domain + '.'):
|
||||
host = host[len(domain) + 1:]
|
||||
break
|
||||
if re.match(r'^\d+\.\d+\.\d+\.\d+$', host):
|
||||
# an IP has no subdomains; sslip.io resolves <anything>.<ip>.sslip.io
|
||||
base = host + '.sslip.io'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue