fix: Make www case-sensitive when detecting link starts (#3770)

This commit is contained in:
Awraam
2025-10-06 21:21:10 -06:00
committed by GitHub
parent e3c0d3e208
commit 626d961335
3 changed files with 23 additions and 4 deletions
+5 -2
View File
@@ -408,12 +408,15 @@ const inlineGfm: Record<InlineKeys, RegExp> = {
...inlineNormal,
emStrongRDelimAst: emStrongRDelimAstGfm,
emStrongLDelim: emStrongLDelimGfm,
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i')
url: edit(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
.replace('protocol', /[fF][tT][pP]|[hH][tT][tT][pP][sS]?/)
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
.getRegex(),
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
del: /^(~~?)(?=[^\s~])((?:\\[\s\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.!#$%&'*+\/=?_`{\|}~-]+@)))/,
text: edit(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/)
.replace('protocol', /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/)
.getRegex(),
};
/**
+9 -1
View File
@@ -12,4 +12,12 @@
<p><strong><a href="mailto:me@example.com">me@example.com</a></strong></p>
<p><strong><a href="mailto:test@test.com">test@test.com</a></strong></p>
<p><strong><a href="mailto:test@test.com">test@test.com</a></strong></p>
<p><a href="http://www.example.com">www.example.com</a></p>
<p>Www.example.com</p>
<p>WWW.example.com</p>
<p>(See <a href="hTtPS://example.com/fhqwhgads">hTtPS://example.com/fhqwhgads</a>.)</p>
+9 -1
View File
@@ -12,4 +12,12 @@ hTtP://fOo.CoM
**me@example.com**
__test@test.com__
__test@test.com__
www.example.com
Www.example.com
WWW.example.com
(See hTtPS://example.com/fhqwhgads.)