From 7a4a6d0d19d1933ce87f51242163fba6676dc7ba Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 2 Apr 2022 13:23:32 +0530 Subject: [PATCH] Report document URL in domready event as well --- resources/scraper.js | 4 ++-- src/calibre/scraper/simple_backend.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/scraper.js b/resources/scraper.js index 4637f45521..dcf4ebfe8c 100644 --- a/resources/scraper.js +++ b/resources/scraper.js @@ -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)}); } })(); diff --git a/src/calibre/scraper/simple_backend.py b/src/calibre/scraper/simple_backend.py index 7dfad9ec2b..3d393eb837 100644 --- a/src/calibre/scraper/simple_backend.py +++ b/src/calibre/scraper/simple_backend.py @@ -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