Skip to content

Commit

Permalink
Support for domain names with two hyphens (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrasser authored Dec 4, 2024
1 parent 09ec1d8 commit 9183db6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/linkifyjs/src/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function init({ groups }) {

// Hyphen can jump back to a domain name
const EmailDomainHyphen = tt(EmailDomain, tk.HYPHEN); // parsed string starts with local email info + @ with a potential domain name
tt(EmailDomainHyphen, tk.HYPHEN, EmailDomainHyphen);
ta(EmailDomainHyphen, groups.domain, EmailDomain);
ta(Email, groups.domain, EmailDomain);
tt(Email, tk.DOT, EmailDomainDot);
Expand All @@ -157,6 +158,7 @@ export function init({ groups }) {
// (but not TLDs)
const DomainHyphen = tt(Domain, tk.HYPHEN); // domain followed by hyphen
const DomainDot = tt(Domain, tk.DOT); // domain followed by DOT
tt(DomainHyphen, tk.HYPHEN, DomainHyphen);
ta(DomainHyphen, groups.domain, Domain);
ta(DomainDot, localpartAccepting, Localpart);
ta(DomainDot, groups.domain, Domain);
Expand Down
2 changes: 2 additions & 0 deletions test/spec/linkifyjs/parser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ const tests = [
['https://google.com', '\ufffcthis'],
],
['some string with somefile.mp4 token', [Text], ['some string with somefile.mp4 token']],
['hp--community.force.com', [Url], ['hp--community.force.com']],
['[email protected]', [Email], ['[email protected]']],
];

describe('linkifyjs/parser#run()', () => {
Expand Down

0 comments on commit 9183db6

Please sign in to comment.