logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://hacktivis.me/git/searx.git
commit: 8911233e3e1d1b6f1ed1c81577c012de57ca62b8
parent e93f5314d745ca389858fdf53f355d8c28928507
Author: Cqoicebordel <Cqoicebordel@users.noreply.github.com>
Date:   Thu, 18 Jun 2015 14:27:15 +0200

Use parsed_url

Diffstat:

Msearx/plugins/tracker_url_remover.py14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git 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