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