@@ -0,0 +1,44 @@
2+searx is free software: you can redistribute it and/or modify
3+it under the terms of the GNU Affero General Public License as published by
4+the Free Software Foundation, either version 3 of the License, or
5+(at your option) any later version.
7+searx is distributed in the hope that it will be useful,
8+but WITHOUT ANY WARRANTY; without even the implied warranty of
9+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+GNU Affero General Public License for more details.
12+You should have received a copy of the GNU Affero General Public License
13+along with searx. If not, see < http://www.gnu.org/licenses/ >.
15+(C) 2015 by Adam Tauber, <asciimoo@gmail.com>
18+from flask.ext.babel import gettext
20+from urlparse import urlunparse
22+regexes = {re.compile(r'utm_[^&]+&?'),
23+ re.compile(r'(wkey|wemail)[^&]+&?'),
26+name = gettext('Tracker URL remover')
27+description = gettext('Remove trackers arguments from the returned URL')
31+def on_result(request, ctx):
32+ query = ctx['result']['parsed_url'].query
38+ query = reg.sub('', query)
40+ if query != ctx['result']['parsed_url'].query:
41+ ctx['result']['parsed_url'] = ctx['result']['parsed_url']._replace(query=query)
42+ ctx['result']['url'] = urlunparse(ctx['result']['parsed_url'])