Fix invalid URL handling in statusbar

This commit is contained in:
Florian Bruhin 2017-04-24 07:47:58 +02:00
parent 38294c1ca6
commit b632fe3285
2 changed files with 7 additions and 5 deletions

View File

@ -138,6 +138,8 @@ class UrlText(textbase.TextBase):
"""
if url is None:
self._normal_url = None
elif not url.isValid():
self._normal_url = "Invalid URL!"
else:
self._normal_url = urlutils.safe_display_url(url)
self._normal_url_type = UrlType.normal

View File

@ -71,12 +71,12 @@ def test_set_url(url_widget, url_text, expected, which):
"""Test text when hovering over a percent encoded link."""
qurl = QUrl(url_text)
if which == 'normal':
if not qurl.isValid():
with pytest.raises(urlutils.InvalidUrlError):
url_widget.set_url(qurl)
if url_text is None:
return
else:
url_widget.set_url(qurl)
if not qurl.isValid():
# Special case for the invalid URL above
expected = "Invalid URL!"
url_widget.set_url(qurl)
else:
url_widget.set_hover_url(url_text)