mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: Make www case-sensitive when detecting link starts (#3770)
This commit is contained in:
+5
-2
@@ -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(),
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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.)
|
||||
|
||||
Reference in New Issue
Block a user