Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ const inlineGfm: Record<InlineKeys, RegExp> = {
delRDelim,
url: edit(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
.replace('protocol', _caseInsensitiveProtocol)
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/)
.getRegex(),
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
Expand Down
30 changes: 30 additions & 0 deletions test/unit/Lexer.test.js
Comment thread
UziTech marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,36 @@ paragraph
],
});
});

it('url email domain ending in _ or - is not autolinked (GFM)', () => {
// A domain must not end in `_` or `-`; the whole email autolink is
// rejected and rendered as plain text, with the domain kept intact.
expectInlineTokens({
md: 'foo@bar.com_',
options: { gfm: true },
tokens: [
{
type: 'text',
raw: 'foo@bar.com_',
text: 'foo@bar.com_',
escaped: false,
},
],
});

expectInlineTokens({
md: 'foo@bar.com-',
options: { gfm: true },
tokens: [
{
type: 'text',
raw: 'foo@bar.com-',
text: 'foo@bar.com-',
escaped: false,
},
],
});
});
});

it('text', () => {
Expand Down