improve https rewrite code

This commit is contained in:
Thomas Pointhuber 2014-10-15 14:47:03 +02:00
parent 0616d26feb
commit bb126da0fb
2 changed files with 10 additions and 4 deletions

View File

@ -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)))

View File

@ -224,10 +224,14 @@ def index():
# process rules
for rule in rules:
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)