parent
0867a95abb
commit
4aa807032f
|
|
@ -123,26 +123,24 @@ def data_for_url(url: QUrl) -> tuple[str, bytes]:
|
|||
|
||||
path = url.path()
|
||||
host = url.host()
|
||||
query = url.query()
|
||||
# A url like "qute:foo" is split as "scheme:path", not "scheme:host".
|
||||
log.misc.debug("url: {}, path: {}, host {}".format(
|
||||
url.toDisplayString(), path, host))
|
||||
if not path or not host:
|
||||
new_url = QUrl()
|
||||
new_url.setScheme('qute')
|
||||
# When path is absent, e.g. qute://help (with no trailing slash)
|
||||
if host:
|
||||
new_url.setHost(host)
|
||||
# When host is absent, e.g. qute:help
|
||||
else:
|
||||
new_url.setHost(path)
|
||||
|
||||
if not host:
|
||||
# Redirect qute:help -> qute://help/
|
||||
new_url = QUrl(url)
|
||||
new_url.setHost(path)
|
||||
new_url.setPath('/')
|
||||
if query:
|
||||
new_url.setQuery(query)
|
||||
if new_url.host(): # path was a valid host
|
||||
raise Redirect(new_url)
|
||||
|
||||
if not path:
|
||||
# Redirect qute://help -> qute://help/
|
||||
new_url = QUrl(url)
|
||||
new_url.setPath('/')
|
||||
raise Redirect(new_url)
|
||||
|
||||
try:
|
||||
handler = _HANDLERS[host]
|
||||
except KeyError:
|
||||
|
|
|
|||
Loading…
Reference in New Issue