Unify auto_search/addressbar_dns_lookup
This commit is contained in:
parent
833da4a8e5
commit
88ea6e62b1
1
TODO
1
TODO
@ -46,7 +46,6 @@ Minor features
|
||||
Hiding scrollbars
|
||||
:bind
|
||||
Ctrl+A/X to increase/decrease last number in URL
|
||||
unify dns/autosearch
|
||||
position remembering
|
||||
multiple commands with ;
|
||||
|
||||
|
@ -20,16 +20,16 @@
|
||||
# wrapsearch: bool, whether to wrap search to the top when arriving at the end.
|
||||
# startpage: The default pages to open at the start, multiple pages can be
|
||||
# separated with commas.
|
||||
# addressbar_dns_lookup: bool, whether to do a lookup in the DNS to figure out
|
||||
# if something is a search term or not. Might be slow.
|
||||
# auto_search: bool, whether to start a search automatically when something
|
||||
# which is not an url is entered.
|
||||
# auto_search: Whether to start a search automatically when something
|
||||
# which is not an url is entered.
|
||||
# true/naive: Use simple/naive check
|
||||
# dns: Use DNS matching (might be slow)
|
||||
# false: Never search automatically
|
||||
show_completion = true
|
||||
ignorecase = true
|
||||
wrapsearch = true
|
||||
startpage = http://www.duckduckgo.com/
|
||||
addressbar_dns_lookup = false
|
||||
auto_search = true
|
||||
auto_search = fuzzy
|
||||
|
||||
[tabbar]
|
||||
# movable: bool, whether tabs should be movable
|
||||
|
@ -49,7 +49,7 @@ def fuzzy_url(url):
|
||||
"""
|
||||
u = qurl(url)
|
||||
urlstr = urlstring(url)
|
||||
if (not config.config.getboolean('general', 'auto_search')) or is_url(u):
|
||||
if is_url(u):
|
||||
# probably an address
|
||||
logging.debug("url is a fuzzy address")
|
||||
newurl = QUrl.fromUserInput(urlstr)
|
||||
@ -94,14 +94,29 @@ def is_url(url):
|
||||
"""Return True if url (QUrl) seems to be a valid URL."""
|
||||
urlstr = urlstring(url)
|
||||
logging.debug('Checking if "{}" is an URL'.format(urlstr))
|
||||
|
||||
try:
|
||||
autosearch = config.config.getboolean('general', 'auto_search')
|
||||
except ValueError:
|
||||
autosearch = config.config.get('general', 'auto_search')
|
||||
else:
|
||||
if autosearch:
|
||||
autosearch = 'naive'
|
||||
else:
|
||||
autosearch = None
|
||||
|
||||
if autosearch is None:
|
||||
# no autosearch, so everything is an URL.
|
||||
return True
|
||||
|
||||
if ' ' in urlstr:
|
||||
# An URL will never contain a space
|
||||
logging.debug('Contains space -> no url')
|
||||
return False
|
||||
elif config.config.getboolean('general', 'addressbar_dns_lookup'):
|
||||
elif autosearch == 'dns':
|
||||
logging.debug('Checking via DNS')
|
||||
return _is_url_dns(QUrl.fromUserInput(urlstr))
|
||||
else:
|
||||
elif autosearch == 'naive':
|
||||
logging.debug('Checking via naive check')
|
||||
return _is_url_naive(url)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user