1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #18476 from Snuffleupagus/viewer-mv-docBaseUrl

Re-factor how the "docBaseUrl" API-option is set in the viewer
This commit is contained in:
Tim van der Meij 2024-07-22 17:29:18 +02:00 committed by GitHub
commit deaac2839e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 8 deletions

View file

@ -854,7 +854,13 @@ const PDFViewerApplication = {
}
if (isDataScheme(url)) {
this._hideViewBookmark();
} else if (
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("MOZCENTRAL || CHROME")
) {
AppOptions.set("docBaseUrl", this.baseUrl);
}
let title = getPdfFilenameFromUrl(url, "");
if (!title) {
try {
@ -996,13 +1002,6 @@ const PDFViewerApplication = {
/* downloadUrl = */ args.url
);
}
// Always set `docBaseUrl` in development mode, and in the (various)
// extension builds.
if (typeof PDFJSDev === "undefined") {
AppOptions.set("docBaseUrl", document.URL.split("#", 1)[0]);
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
AppOptions.set("docBaseUrl", this.baseUrl);
}
// Set the necessary API parameters, using all the available options.
const apiParams = AppOptions.getAll(OptionKind.API);

View file

@ -345,7 +345,7 @@ const defaultOptions = {
},
docBaseUrl: {
/** @type {string} */
value: "",
value: typeof PDFJSDev === "undefined" ? document.URL.split("#", 1)[0] : "",
kind: OptionKind.API,
},
enableHWA: {