Add Option url.open_base_url
when set to true, invoking a searchengine shortcut without argument opens the baseurl of that searchengine instead of DEFAULT searchengine
This commit is contained in:
parent
541abb2324
commit
42ac3dcda0
@ -1445,6 +1445,12 @@ url.incdec_segments:
|
||||
desc: URL segments where `:navigate increment/decrement` will search for
|
||||
a number.
|
||||
|
||||
url.open_base_url:
|
||||
type: Bool
|
||||
default: false
|
||||
desc: Invoking `:open {shortcut}` (without argument), where {shortcut} is a search engine shortcut
|
||||
will open the base url of the shortcut instead of using the default search engine.
|
||||
|
||||
url.searchengines:
|
||||
default:
|
||||
DEFAULT: https://duckduckgo.com/?q={}
|
||||
|
@ -102,6 +102,13 @@ def _get_search_url(txt):
|
||||
engine = 'DEFAULT'
|
||||
template = config.val.url.searchengines[engine]
|
||||
url = qurl_from_user_input(template.format(urllib.parse.quote(term)))
|
||||
|
||||
if config.val.url.open_base_url:
|
||||
try:
|
||||
search_url = urllib.parse.urlparse(config.val.url.searchengines[term])
|
||||
url = QUrl('{}://{}'.format(search_url.scheme, search_url.netloc))
|
||||
except KeyError:
|
||||
pass
|
||||
qtutils.ensure_valid(url)
|
||||
return url
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user