mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-02-08 00:21:11 +01:00
Merge pull request #20565 from kairosci/fix-bug-20557
fix: Fix mailto links truncated at dash
This commit is contained in:
commit
384c6208b2
@ -209,4 +209,14 @@ describe("autolinker", function () {
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should correctly find emails with hyphens in domain (bug 20557)", function () {
|
||||||
|
testLinks([
|
||||||
|
[
|
||||||
|
"john.doe@faculity.uni-cityname.tld",
|
||||||
|
"mailto:john.doe@faculity.uni-cityname.tld",
|
||||||
|
],
|
||||||
|
["john.doe@uni-cityname.tld", "mailto:john.doe@uni-cityname.tld"],
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -138,7 +138,7 @@ class Autolinker {
|
|||||||
static findLinks(text) {
|
static findLinks(text) {
|
||||||
// Regex can be tested and verified at https://regex101.com/r/rXoLiT/2.
|
// Regex can be tested and verified at https://regex101.com/r/rXoLiT/2.
|
||||||
this.#regex ??=
|
this.#regex ??=
|
||||||
/\b(?:https?:\/\/|mailto:|www\.)(?:[\S--[\p{P}<>]]|\/|[\S--[\[\]]]+[\S--[\p{P}<>]])+|(?=\p{L})[\S--[@\p{Ps}\p{Pe}<>]]+@([\S--[\p{P}<>]]+(?:\.[\S--[\p{P}<>]]+)+)/gmv;
|
/\b(?:https?:\/\/|mailto:|www\.)(?:[\S--[\p{P}<>]]|\/|[\S--[\[\]]]+[\S--[\p{P}<>]])+|(?=\p{L})[\S--[@\p{Ps}\p{Pe}<>]]+@([\S--[[\p{P}--\-]<>]]+(?:\.[\S--[[\p{P}--\-]<>]]+)+)/gmv;
|
||||||
|
|
||||||
const [normalizedText, diffs] = normalize(text, { ignoreDashEOL: true });
|
const [normalizedText, diffs] = normalize(text, { ignoreDashEOL: true });
|
||||||
const matches = normalizedText.matchAll(this.#regex);
|
const matches = normalizedText.matchAll(this.#regex);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user