mirror of
https://github.com/searx/searx
synced 2025-01-28 08:49:19 +01:00
improve https rewrite code
This commit is contained in:
parent
0616d26feb
commit
bb126da0fb
@ -137,3 +137,5 @@ def load_https_rules(rules_path):
|
|||||||
|
|
||||||
# append ruleset
|
# append ruleset
|
||||||
https_rules.append(ruleset)
|
https_rules.append(ruleset)
|
||||||
|
|
||||||
|
print(' * {n} https-rules loaded'.format(n=len(https_rules)))
|
||||||
|
@ -224,10 +224,14 @@ def index():
|
|||||||
|
|
||||||
# process rules
|
# process rules
|
||||||
for rule in rules:
|
for rule in rules:
|
||||||
# TODO, precompile rule
|
try:
|
||||||
p = re.compile(rule[0])
|
# TODO, precompile rule
|
||||||
# rewrite url if possible
|
p = re.compile(rule[0])
|
||||||
new_result_url = p.sub(rule[1], result['url'])
|
|
||||||
|
# rewrite url if possible
|
||||||
|
new_result_url = p.sub(rule[1], result['url'])
|
||||||
|
except:
|
||||||
|
break
|
||||||
|
|
||||||
# parse new url
|
# parse new url
|
||||||
new_parsed_url = urlparse(new_result_url)
|
new_parsed_url = urlparse(new_result_url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user