diff options
author | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2015-06-18 14:27:15 +0200 |
---|---|---|
committer | Cqoicebordel <Cqoicebordel@users.noreply.github.com> | 2015-06-18 14:27:15 +0200 |
commit | 8911233e3e1d1b6f1ed1c81577c012de57ca62b8 (patch) | |
tree | 27050936235008baac010f8760bfe6d2b90301bc /searx | |
parent | e93f5314d745ca389858fdf53f355d8c28928507 (diff) | |
download | searxng-8911233e3e1d1b6f1ed1c81577c012de57ca62b8.tar.gz searxng-8911233e3e1d1b6f1ed1c81577c012de57ca62b8.zip |
Use parsed_url
Diffstat (limited to 'searx')
-rw-r--r-- | searx/plugins/tracker_url_remover.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/searx/plugins/tracker_url_remover.py b/searx/plugins/tracker_url_remover.py index f6ecc2126..ed71c94d3 100644 --- a/searx/plugins/tracker_url_remover.py +++ b/searx/plugins/tracker_url_remover.py @@ -17,6 +17,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >. from flask.ext.babel import gettext import re +from urlparse import urlunparse regexes = {re.compile(r'utm_[^&]+&?'), re.compile(r'(wkey|wemail)[^&]+&?'), @@ -28,17 +29,16 @@ default_on = True def on_result(request, ctx): - splited_url = ctx['result']['url'].split('?') + query = ctx['result']['parsed_url'].query - if len(splited_url) is not 2: + if query == "": return True for reg in regexes: - splited_url[1] = reg.sub('', splited_url[1]) + query = reg.sub('', query) - if splited_url[1] == "": - ctx['result']['url'] = splited_url[0] - else: - ctx['result']['url'] = splited_url[0] + '?' + splited_url[1] + if query != ctx['result']['parsed_url'].query: + ctx['result']['parsed_url'] = ctx['result']['parsed_url']._replace(query=query) + ctx['result']['url'] = urlunparse(ctx['result']['parsed_url']) return True |