fuzzy_url: Raise InvalidUrlError on empty URLs.
Before we raised QtValueError (via qtutils.ensure_valid), but maybe there are more callers out there which call fuzzy_url with an empty input - and it makes more sense to raise InvalidUrlError which gets displayed to the user than raising QtValueError which is more like an assertion.
This commit is contained in:
parent
14042403f6
commit
312daca2b0
@ -43,6 +43,7 @@ Fixed
|
||||
the tab it belongs to.
|
||||
- Fixed crash when downloading a file without any path information (e.g a
|
||||
magnet link).
|
||||
- Fixed crashes when opening an empty URL (e.g. via pasting).
|
||||
|
||||
v0.5.1
|
||||
------
|
||||
|
@ -172,6 +172,7 @@ def fuzzy_url(urlstr, cwd=None, relative=False, do_search=True):
|
||||
"""
|
||||
urlstr = urlstr.strip()
|
||||
expanded = os.path.expanduser(urlstr)
|
||||
|
||||
if os.path.isabs(expanded):
|
||||
path = expanded
|
||||
elif relative and cwd:
|
||||
@ -199,7 +200,7 @@ def fuzzy_url(urlstr, cwd=None, relative=False, do_search=True):
|
||||
url = qurl_from_user_input(urlstr)
|
||||
log.url.debug("Converting fuzzy term {} to URL -> {}".format(
|
||||
urlstr, url.toDisplayString()))
|
||||
if do_search and config.get('general', 'auto-search'):
|
||||
if do_search and config.get('general', 'auto-search') and urlstr:
|
||||
qtutils.ensure_valid(url)
|
||||
else:
|
||||
if not url.isValid():
|
||||
|
@ -233,6 +233,11 @@ class TestFuzzyUrl:
|
||||
with pytest.raises(exception):
|
||||
urlutils.fuzzy_url('foo', do_search=do_search)
|
||||
|
||||
@pytest.mark.parametrize('url', ['', ' '])
|
||||
def test_empty(self, url):
|
||||
with pytest.raises(urlutils.InvalidUrlError):
|
||||
urlutils.fuzzy_url(url, do_search=True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('url, special', [
|
||||
('file:///tmp/foo', True),
|
||||
|
Loading…
Reference in New Issue
Block a user