parent
5c769d8000
commit
6b89eb43a2
@ -86,6 +86,7 @@ Changed
|
||||
- `:tab-move +/-` now wraps around if `tabs -> wrap` is `true`.
|
||||
- When a subprocess (like launched by `:spawn`) fails, its stdout/stderr is now
|
||||
logged to the console.
|
||||
- A search engine name can now contain any non-space character, like dashes.
|
||||
|
||||
Deprecated
|
||||
~~~~~~~~~~
|
||||
|
@ -62,19 +62,22 @@ def _parse_search_term(s):
|
||||
Return:
|
||||
A (engine, term) tuple, where engine is None for the default engine.
|
||||
"""
|
||||
m = re.search(r'(^\w+)\s+(.+)($|\s+)', s)
|
||||
if m:
|
||||
engine = m.group(1)
|
||||
s = s.strip()
|
||||
splitted = s.split(maxsplit=1)
|
||||
|
||||
if len(splitted) == 2:
|
||||
engine = splitted[0]
|
||||
try:
|
||||
config.get('searchengines', engine)
|
||||
except configexc.NoOptionError:
|
||||
engine = None
|
||||
term = s
|
||||
else:
|
||||
term = m.group(2).rstrip()
|
||||
term = splitted[1]
|
||||
else:
|
||||
engine = None
|
||||
term = s
|
||||
|
||||
log.url.debug("engine {}, term '{}'".format(engine, term))
|
||||
return (engine, term)
|
||||
|
||||
|
@ -98,6 +98,7 @@ def urlutils_config_stub(config_stub, monkeypatch):
|
||||
'general': {'auto-search': True},
|
||||
'searchengines': {
|
||||
'test': 'http://www.qutebrowser.org/?q={}',
|
||||
'test-with-dash': 'http://www.example.org/?q={}',
|
||||
'DEFAULT': 'http://www.example.com/?q={}',
|
||||
},
|
||||
}
|
||||
@ -247,6 +248,8 @@ def test_special_urls(url, special):
|
||||
('test testfoo ', 'www.qutebrowser.org', 'q=testfoo'),
|
||||
('!python testfoo', 'www.example.com', 'q=%21python testfoo'),
|
||||
('blub testfoo', 'www.example.com', 'q=blub testfoo'),
|
||||
('stripped ', 'www.example.com', 'q=stripped'),
|
||||
('test-with-dash testfoo', 'www.example.org', 'q=testfoo'),
|
||||
])
|
||||
def test_get_search_url(urlutils_config_stub, url, host, query):
|
||||
"""Test _get_search_url().
|
||||
|
Loading…
Reference in New Issue
Block a user