qutescheme: Improve handling of invalid path -> host redirects
This commit is contained in:
parent
4aa807032f
commit
2ae3086244
|
|
@ -132,8 +132,9 @@ def data_for_url(url: QUrl) -> tuple[str, bytes]:
|
|||
new_url = QUrl(url)
|
||||
new_url.setHost(path)
|
||||
new_url.setPath('/')
|
||||
if new_url.host(): # path was a valid host
|
||||
raise Redirect(new_url)
|
||||
if not new_url.host(): # Valid path but not valid host
|
||||
raise UrlInvalidError(f"Invalid host (from path): {path!r}")
|
||||
raise Redirect(new_url)
|
||||
|
||||
if not path:
|
||||
# Redirect qute://help -> qute://help/
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class TestDataForUrl:
|
|||
def test_invalid_redirect(self) -> None:
|
||||
url = QUrl("qute:-")
|
||||
with pytest.raises(
|
||||
qutescheme.NotFoundError, match="No handler found for qute:-"
|
||||
qutescheme.UrlInvalidError, match=r"Invalid host \(from path\): '-'"
|
||||
):
|
||||
qutescheme.data_for_url(url)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue