Merge pull request #3215 from deewakar/issue3161

Add trailing slash to qute://help pages
This commit is contained in:
Florian Bruhin 2017-11-03 11:49:31 +01:00 committed by GitHub
commit 1536c098cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 7 deletions

View File

@ -138,14 +138,23 @@ def data_for_url(url):
"""
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 path and not host:
if not path or not host:
new_url = QUrl()
new_url.setScheme('qute')
new_url.setHost(path)
# 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)
new_url.setPath('/')
if query:
new_url.setQuery(query)
if new_url.host(): # path was a valid host
raise Redirect(new_url)

View File

@ -55,6 +55,14 @@ Feature: Special qute:// pages
And I hint with args "links normal" and follow a
Then qute://help/quickstart.html should be loaded
Scenario: Opening a link with qute://help
When the documentation is up to date
And I run :tab-only
And I open qute://help without waiting
And I wait until qute://help/ is loaded
And I hint with args "links normal" and follow a
Then qute://help/quickstart.html should be loaded
# :history
Scenario: :history without arguments
@ -139,12 +147,12 @@ Feature: Special qute:// pages
Scenario: Running :pyeval
When I run :debug-pyeval 1+1
And I wait until qute://pyeval is loaded
And I wait until qute://pyeval/ is loaded
Then the page should contain the plaintext "2"
Scenario: Causing exception in :pyeval
When I run :debug-pyeval 1/0
And I wait until qute://pyeval is loaded
And I wait until qute://pyeval/ is loaded
Then the page should contain the plaintext "ZeroDivisionError"
Scenario: Running :pyeval with --quiet
@ -158,7 +166,7 @@ Feature: Special qute:// pages
And I run :message-warning the-warning-message
And I run :message-info the-info-message
And I run :messages
Then qute://log?level=info should be loaded
Then qute://log/?level=info should be loaded
And the error "the-error-message" should be shown
And the warning "the-warning-message" should be shown
And the page should contain the plaintext "the-error-message"
@ -170,7 +178,7 @@ Feature: Special qute:// pages
And I run :message-warning the-warning-message
And I run :message-info the-info-message
And I run :messages warning
Then qute://log?level=warning should be loaded
Then qute://log/?level=warning should be loaded
And the error "the-error-message" should be shown
And the warning "the-warning-message" should be shown
And the page should contain the plaintext "the-error-message"
@ -182,7 +190,7 @@ Feature: Special qute:// pages
And I run :message-warning the-warning-message
And I run :message-info the-info-message
And I run :messages info
Then qute://log?level=info should be loaded
Then qute://log/?level=info should be loaded
And the error "the-error-message" should be shown
And the warning "the-warning-message" should be shown
And the page should contain the plaintext "the-error-message"