summaryrefslogtreecommitdiff
path: root/searx/query.py
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2017-03-01 17:11:51 -0600
committerAdam Tauber <asciimoo@gmail.com>2017-03-18 23:44:21 +0100
commitfd65c1292179fb082e965a1ee6a88b9298a54fc1 (patch)
treebd2cc7302a1b7d81f2294aab1ad1de0aedd0bdd8 /searx/query.py
parent805fb02ed1fb7f8e006c8def7d76a0d1958364bf (diff)
downloadsearxng-fd65c1292179fb082e965a1ee6a88b9298a54fc1.tar.gz
searxng-fd65c1292179fb082e965a1ee6a88b9298a54fc1.zip
make search language handling less strict
languages.py can change, so users may query on a language that is not on the list anymore, even if it is still recognized by a few engines. also made no and nb the same because they seem to return the same, though most engines will only support one or the other.
Diffstat (limited to 'searx/query.py')
-rw-r--r--searx/query.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/searx/query.py b/searx/query.py
index 66e38711c..b8b1c0d2f 100644
--- a/searx/query.py
+++ b/searx/query.py
@@ -24,7 +24,7 @@ from searx.engines import (
import string
import re
-VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(\-[A-Z]{2})?$')
+VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(-[a-zA-Z]{2})?$')
class RawTextQuery(object):
@@ -68,7 +68,7 @@ class RawTextQuery(object):
# this force a language
if query_part[0] == ':':
- lang = query_part[1:].lower()
+ lang = query_part[1:].lower().replace('_', '-')
# user may set a valid, yet not selectable language
if VALID_LANGUAGE_CODE.match(lang):
@@ -86,7 +86,7 @@ class RawTextQuery(object):
or lang_id.startswith(lang)\
or lang == lang_name\
or lang == english_name\
- or lang.replace('_', ' ') == country:
+ or lang.replace('-', ' ') == country:
parse_next = True
self.languages.append(lang_id)
# to ensure best match (first match is not necessarily the best one)