mirror of
https://github.com/searx/searx
synced 2024-12-27 19:45:34 +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
|
||||
https_rules.append(ruleset)
|
||||
|
||||
print(' * {n} https-rules loaded'.format(n=len(https_rules)))
|
||||
|
@ -224,10 +224,14 @@ def index():
|
||||
|
||||
# process rules
|
||||
for rule in rules:
|
||||
# TODO, precompile rule
|
||||
p = re.compile(rule[0])
|
||||
# rewrite url if possible
|
||||
new_result_url = p.sub(rule[1], result['url'])
|
||||
try:
|
||||
# TODO, precompile rule
|
||||
p = re.compile(rule[0])
|
||||
|
||||
# rewrite url if possible
|
||||
new_result_url = p.sub(rule[1], result['url'])
|
||||
except:
|
||||
break
|
||||
|
||||
# parse new url
|
||||
new_parsed_url = urlparse(new_result_url)
|
||||
|
Loading…
Reference in New Issue
Block a user