Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-factor how the "docBaseUrl" API-option is set in the viewer #18476

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ const defaultOptions = {
},
docBaseUrl: {
/** @type {string} */
value: "",
value: typeof PDFJSDev === "undefined" ? document.URL.split("#", 1)[0] : "",
kind: OptionKind.API,
},
enableHWA: {
Expand Down