Simplify hostname parsing

This commit is contained in:
Christian M. Adams
2021-05-25 15:13:56 -04:00
parent d607dfd5d8
commit 536c02dc55
2 changed files with 3 additions and 8 deletions

View File

@@ -47,11 +47,10 @@ def construct_rsyslog_conf_template(settings=settings):
return tmpl
if protocol.startswith('http'):
scheme = 'https'
# urlparse requires '//' to be provided if scheme is not specified
original_parsed = urlparse.urlsplit(host)
if (not original_parsed.scheme and not host.startswith('//')) or original_parsed.hostname is None:
host = '%s://%s' % (scheme, host)
host = 'https://%s' % (host)
parsed = urlparse.urlsplit(host)
host = escape_quotes(parsed.hostname)