Skip to content

Commit 697ac2a

Browse files
authored
fix: remove quotes at the end of gfm autolink (#2673)
Fixes undefined
1 parent df4eb0e commit 697ac2a

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/Tokenizer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,9 @@ export class Tokenizer {
733733
} while (prevCapZero !== cap[0]);
734734
text = escape(cap[0]);
735735
if (cap[1] === 'www.') {
736-
href = 'http://' + text;
736+
href = 'http://' + cap[0];
737737
} else {
738-
href = text;
738+
href = cap[0];
739739
}
740740
}
741741
return {

src/rules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ inline.gfm = merge({}, inline.normal, {
284284
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
285285
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
286286
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
287-
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
287+
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
288288
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
289289
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
290290
});

test/specs/new/autolinks_quotes.html

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<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>
2+
3+
<p>&#39;<a href="https://www.example.com?test=quote-in-'-url">https://www.example.com?test=quote-in-&#39;-url</a>&#39;</p>

test/specs/new/autolinks_quotes.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"https://www.example.com?test=quote-in-"-url"
2+
3+
'https://www.example.com?test=quote-in-'-url'

0 commit comments

Comments
 (0)