Skip to content

Commit

Permalink
Merge pull request mozilla#18430 from Snuffleupagus/pr-18417-followup
Browse files Browse the repository at this point in the history
Fix `DOMFilterFactory.#createUrl` in MOZCENTRAL builds (18417 PR follow-up)
  • Loading branch information
Snuffleupagus authored Jul 15, 2024
2 parents 87e74a7 + 4c45948 commit f9e3b6b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/display/display_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,20 @@ class DOMFilterFactory extends BaseFilterFactory {
}

#createUrl(id) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
if (this.#baseUrl === undefined) {
const url = this.#document.URL;
if (url === this.#document.baseURI) {
// No `<base>`-element present, hence a relative URL should work.
this.#baseUrl = "";
} else if (isDataScheme(url)) {
if (this.#baseUrl === undefined) {
// Unless a `<base>`-element is present a relative URL should work.
this.#baseUrl = "";

const url = this.#document.URL;
if (url !== this.#document.baseURI) {
if (isDataScheme(url)) {
warn('#createUrl: ignore "data:"-URL for performance reasons.');
this.#baseUrl = "";
} else {
this.#baseUrl = url.split("#", 1)[0];
}
}
return `url(${this.#baseUrl}#${id})`;
}
return `url(${id})`;
return `url(${this.#baseUrl}#${id})`;
}

addFilter(maps) {
Expand Down

0 comments on commit f9e3b6b

Please sign in to comment.