mirror of https://github.com/searxng/searxng.git
add subdomain replacement to hostname_replace.py
This commit is contained in:
parent
3829c253ff
commit
46b78e9f43
|
@ -30,7 +30,9 @@ def on_result(request, search, result):
|
||||||
# (only) on the 'parsed_url'
|
# (only) on the 'parsed_url'
|
||||||
if not replacement:
|
if not replacement:
|
||||||
return False
|
return False
|
||||||
result[parsed] = result[parsed]._replace(netloc=pattern.sub(replacement, result[parsed].netloc))
|
subdomain = pattern.search(result[parsed].netloc).group(1) or ''
|
||||||
|
new_netloc = replacement.replace('(*)', subdomain)
|
||||||
|
result[parsed] = result[parsed]._replace(netloc=pattern.sub(new_netloc, result[parsed].netloc))
|
||||||
result['url'] = urlunparse(result[parsed])
|
result['url'] = urlunparse(result[parsed])
|
||||||
|
|
||||||
for url_field in _url_fields:
|
for url_field in _url_fields:
|
||||||
|
@ -40,7 +42,9 @@ def on_result(request, search, result):
|
||||||
if not replacement:
|
if not replacement:
|
||||||
del result[url_field]
|
del result[url_field]
|
||||||
else:
|
else:
|
||||||
url_src = url_src._replace(netloc=pattern.sub(replacement, url_src.netloc))
|
subdomain = pattern.search(url_src.netloc).group(1) or ''
|
||||||
|
new_netloc = replacement.replace('(*)', subdomain)
|
||||||
|
url_src = url_src._replace(netloc=pattern.sub(new_netloc, url_src.netloc))
|
||||||
result[url_field] = urlunparse(url_src)
|
result[url_field] = urlunparse(url_src)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue