Skip to content
Snippets Groups Projects
Commit f8f75e41 authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Improved server_name parsing.

parent b34a082f
No related branches found
No related tags found
No related merge requests found
......@@ -35,12 +35,13 @@ def setup(interactive=True):
path = os.path.join(nginx_dir, name)
with open(path, 'r') as fo:
vhost = fo.read()
vhost = vhost.replace('\t', ' ')
matching = re.search(r'.*server_name\ +([0-9a-zA-Z\.\-\_\ ]+);.*', vhost)
vhost = re.sub(r'\s+', ' ', vhost)
matching = re.findall(r'[^#][ ]*server_name ([0-9a-zA-Z\.\-\_\ ]+);', vhost)
if not matching:
print('The server_name was not found in: "%s".' % path)
continue
for domain in matching.groups()[0].strip().split(' '):
matching = ' '.join(matching)
for domain in matching.strip().split(' '):
domain = domain.strip()
if domain and domain != 'localhost' and '.' in domain and domain not in domains:
domains.append(domain)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment