|
@@ -17,6 +17,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
|
17
|
17
|
|
18
|
18
|
from flask.ext.babel import gettext
|
19
|
19
|
import re
|
|
20
|
+from urlparse import urlunparse
|
20
|
21
|
|
21
|
22
|
regexes = {re.compile(r'utm_[^&]+&?'),
|
22
|
23
|
re.compile(r'(wkey|wemail)[^&]+&?'),
|
|
@@ -28,17 +29,16 @@ default_on = True
|
28
|
29
|
|
29
|
30
|
|
30
|
31
|
def on_result(request, ctx):
|
31
|
|
- splited_url = ctx['result']['url'].split('?')
|
|
32
|
+ query = ctx['result']['parsed_url'].query
|
32
|
33
|
|
33
|
|
- if len(splited_url) is not 2:
|
|
34
|
+ if query == "":
|
34
|
35
|
return True
|
35
|
36
|
|
36
|
37
|
for reg in regexes:
|
37
|
|
- splited_url[1] = reg.sub('', splited_url[1])
|
|
38
|
+ query = reg.sub('', query)
|
38
|
39
|
|
39
|
|
- if splited_url[1] == "":
|
40
|
|
- ctx['result']['url'] = splited_url[0]
|
41
|
|
- else:
|
42
|
|
- ctx['result']['url'] = splited_url[0] + '?' + splited_url[1]
|
|
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'])
|
43
|
43
|
|
44
|
44
|
return True
|