Merge pull request #16630 from Rob--W/crx-url-hash-init
Correct recognition of fragments at document load
This commit is contained in:
commit
42edc4d895
@ -20,7 +20,15 @@ limitations under the License.
|
||||
var VIEWER_URL = chrome.extension.getURL("content/web/viewer.html");
|
||||
|
||||
function getViewerURL(pdf_url) {
|
||||
return VIEWER_URL + "?file=" + encodeURIComponent(pdf_url);
|
||||
// |pdf_url| may contain a fragment such as "#page=2". That should be passed
|
||||
// as a fragment to the viewer, not encoded in pdf_url.
|
||||
var hash = "";
|
||||
var i = pdf_url.indexOf("#");
|
||||
if (i > 0) {
|
||||
hash = pdf_url.slice(i);
|
||||
pdf_url = pdf_url.slice(0, i);
|
||||
}
|
||||
return VIEWER_URL + "?file=" + encodeURIComponent(pdf_url) + hash;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,6 +42,9 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
||||
}
|
||||
|
||||
AppOptions.set("defaultUrl", defaultUrl);
|
||||
// Ensure that PDFViewerApplication.initialBookmark reflects the current hash,
|
||||
// in case the URL rewrite above results in a different hash.
|
||||
PDFViewerApplication.initialBookmark = location.hash.slice(1);
|
||||
})();
|
||||
|
||||
const ChromeCom = {
|
||||
|
Loading…
Reference in New Issue
Block a user