Merge branch 'forkbong-pretty-hover-url'
This commit is contained in:
commit
d837e3eb91
@ -49,6 +49,7 @@ Changed
|
||||
- `:bind <key>` without a command now shows the existing binding
|
||||
- The optional `colorlog` dependency got removed, as qutebrowser now displays
|
||||
colored logs without it.
|
||||
- URLs are now shown decoded when hovering.
|
||||
|
||||
Fixed
|
||||
-----
|
||||
|
@ -154,10 +154,10 @@ Contributors, sorted by the number of commits in descending order:
|
||||
* meles5
|
||||
* Tarcisio Fedrizzi
|
||||
* Philipp Hansch
|
||||
* Panagiotis Ktistakis
|
||||
* Artur Shaik
|
||||
* Nathan Isom
|
||||
* Thorsten Wißmann
|
||||
* Panagiotis Ktistakis
|
||||
* Kevin Velghe
|
||||
* Austin Anderson
|
||||
* Jimmy
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
"""URL displayed in the statusbar."""
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtProperty, Qt
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtProperty, Qt, QUrl
|
||||
|
||||
from qutebrowser.browser import webview
|
||||
from qutebrowser.mainwindow.statusbar import textbase
|
||||
@ -153,7 +153,12 @@ class UrlText(textbase.TextBase):
|
||||
_text: The text of the hovered link (string)
|
||||
"""
|
||||
if link:
|
||||
self._hover_url = link
|
||||
# We assume that `link` is always be given in a form that generates
|
||||
# a valid QUrl. If this proves to be wrong, we should probably
|
||||
# check and fall back to the text version otherwise.
|
||||
qurl = QUrl(link)
|
||||
assert qurl.isValid(), link
|
||||
self._hover_url = qurl.toDisplayString()
|
||||
else:
|
||||
self._hover_url = None
|
||||
self._update_url()
|
||||
|
@ -76,7 +76,6 @@ def test_set_url(url_widget, url_text):
|
||||
@pytest.mark.parametrize('url_text, title, text', [
|
||||
('http://abc123.com/this/awesome/url.html', 'Awesome site', 'click me!'),
|
||||
('https://supersecret.gov/nsa/files.txt', 'Secret area', None),
|
||||
('Th1$ i$ n0t @ n0rm@L uRL! P@n1c! <-->', 'Probably spam', 'definitely'),
|
||||
(None, None, 'did I break?!')
|
||||
])
|
||||
def test_set_hover_url(url_widget, url_text, title, text):
|
||||
@ -90,6 +89,20 @@ def test_set_hover_url(url_widget, url_text, title, text):
|
||||
assert url_widget._urltype == url.UrlType.normal
|
||||
|
||||
|
||||
@pytest.mark.parametrize('url_text, expected', [
|
||||
('http://test.gr/%CE%B1%CE%B2%CE%B3%CE%B4.txt', 'http://test.gr/αβγδ.txt'),
|
||||
('http://test.ru/%D0%B0%D0%B1%D0%B2%D0%B3.txt', 'http://test.ru/абвг.txt'),
|
||||
('http://test.com/s%20p%20a%20c%20e.txt', 'http://test.com/s p a c e.txt'),
|
||||
('http://test.com/%22quotes%22.html', 'http://test.com/%22quotes%22.html'),
|
||||
('http://username:secret%20password@test.com', 'http://username@test.com')
|
||||
])
|
||||
def test_set_hover_url_encoded(url_widget, url_text, expected):
|
||||
"""Test text when hovering over a percent encoded link."""
|
||||
url_widget.set_hover_url(url_text, 'title', 'text')
|
||||
assert url_widget.text() == expected
|
||||
assert url_widget._urltype == url.UrlType.hover
|
||||
|
||||
|
||||
@pytest.mark.parametrize('status, expected', [
|
||||
(webview.LoadStatus.success, url.UrlType.success),
|
||||
(webview.LoadStatus.success_https, url.UrlType.success_https),
|
||||
|
Loading…
Reference in New Issue
Block a user