Skip to content

Commit

Permalink
fix: remove quotes at the end of gfm autolink (#2673)
Browse files Browse the repository at this point in the history
Fixes undefined
  • Loading branch information
UziTech authored Dec 7, 2022
1 parent df4eb0e commit 697ac2a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,9 @@ export class Tokenizer {
} while (prevCapZero !== cap[0]);
text = escape(cap[0]);
if (cap[1] === 'www.') {
href = 'http://' + text;
href = 'http://' + cap[0];
} else {
href = text;
href = cap[0];
}
}
return {
Expand Down
2 changes: 1 addition & 1 deletion src/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ inline.gfm = merge({}, inline.normal, {
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
});
Expand Down
3 changes: 3 additions & 0 deletions test/specs/new/autolinks_quotes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>&quot;<a href="https://www.example.com?test=quote-in-%22-url">https://www.example.com?test=quote-in-&quot;-url</a>&quot;</p>

<p>&#39;<a href="https://www.example.com?test=quote-in-'-url">https://www.example.com?test=quote-in-&#39;-url</a>&#39;</p>
3 changes: 3 additions & 0 deletions test/specs/new/autolinks_quotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"https://www.example.com?test=quote-in-"-url"

'https://www.example.com?test=quote-in-'-url'

1 comment on commit 697ac2a

@vercel
Copy link

@vercel vercel bot commented on 697ac2a Dec 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.