Report document URL in domready event as well

This commit is contained in:
Kovid Goyal 2022-04-02 13:23:32 +05:30
parent a0c9005d69
commit 7a4a6d0d19
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 3 deletions

View File

@ -21,7 +21,7 @@
send_msg({type: 'print', text: text});
}
if (!document.location.href.startsWith('chrome-error:') && !document.location.href.startsWith('about:')) {
send_msg({type: 'domready', html: new XMLSerializer().serializeToString(document)});
if (document.location && document.location.href && !document.location.href.startsWith('chrome-error:') && !document.location.href.startsWith('about:')) {
send_msg({type: 'domready', url: document.location.href, html: new XMLSerializer().serializeToString(document)});
}
})();

View File

@ -16,7 +16,9 @@ from calibre.gui2.webengine import create_script, insert_scripts
def canonicalize_qurl(qurl):
qurl = qurl.adjusted(QUrl.UrlFormattingOption.StripTrailingSlash | QUrl.UrlFormattingOption.NormalizePathSegments)
qurl = qurl.adjusted(
QUrl.UrlFormattingOption.StripTrailingSlash | QUrl.UrlFormattingOption.NormalizePathSegments | QUrl.UrlFormattingOption.RemoveFragment
)
if qurl.path() == '/':
qurl = qurl.adjusted(QUrl.UrlFormattingOption.RemovePath)
return qurl