diff --git a/test/integration/autolinker_spec.mjs b/test/integration/autolinker_spec.mjs index 455f106d6..4492fa556 100644 --- a/test/integration/autolinker_spec.mjs +++ b/test/integration/autolinker_spec.mjs @@ -88,4 +88,37 @@ describe("autolinker", function () { ); }); }); + + describe("pr19449.pdf", function () { + let pages; + + beforeAll(async () => { + pages = await loadAndWait("pr19449.pdf", ".annotationLayer", null, null, { + docBaseUrl: "http://example.com", + enableAutoLinking: true, + }); + }); + + afterAll(async () => { + await closePages(pages); + }); + + it("must not add links that overlap even if the URLs are different", async () => { + await Promise.all( + pages.map(async ([browserName, page]) => { + const linkIds = await page.$$eval( + ".annotationLayer > .linkAnnotation > a", + annotations => + annotations.map(a => a.getAttribute("data-element-id")) + ); + expect(linkIds.length).withContext(`In ${browserName}`).toEqual(1); + linkIds.forEach(id => + expect(id) + .withContext(`In ${browserName}`) + .not.toContain("inferred_link_") + ); + }) + ); + }); + }); }); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 14660ecd3..83fa48a0b 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -276,6 +276,7 @@ !pr6531_1.pdf !pr6531_2.pdf !pr7352.pdf +!pr19449.pdf !bug900822.pdf !bug1392647.pdf !issue918.pdf diff --git a/test/pdfs/pr19449.pdf b/test/pdfs/pr19449.pdf new file mode 100644 index 000000000..90c15d22a Binary files /dev/null and b/test/pdfs/pr19449.pdf differ diff --git a/web/annotation_layer_builder.js b/web/annotation_layer_builder.js index effe83bf6..24c4668c2 100644 --- a/web/annotation_layer_builder.js +++ b/web/annotation_layer_builder.js @@ -327,7 +327,7 @@ class AnnotationLayerBuilder { for (const annotation of this.#annotations) { if ( annotation.annotationType !== AnnotationType.LINK || - annotation.url !== link.url + !annotation.url ) { continue; } diff --git a/web/app.js b/web/app.js index 06b05cfb8..eebe8beaa 100644 --- a/web/app.js +++ b/web/app.js @@ -353,6 +353,7 @@ const PDFViewerApplication = { // Set some specific preferences for tests. if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) { Object.assign(opts, { + docBaseUrl: x => x, enableAltText: x => x === "true", enableAutoLinking: x => x === "true", enableFakeMLManager: x => x === "true",