mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: strip whitespace when normalizing link reference labels (#4091)
This commit is contained in:
+4
-1
@@ -146,7 +146,10 @@ export function trimTrailingBlankLines(str: string) {
|
||||
* keeps the folded label lower case, the form `def.tag` has always used.
|
||||
*/
|
||||
export function normalizeLabel(label: string) {
|
||||
return label.toLowerCase().toUpperCase().toLowerCase();
|
||||
// The spec also asks for leading and trailing spaces, tabs and line endings
|
||||
// to be stripped. Doing it here keeps every call site in agreement: the
|
||||
// definition and the reference have to normalize to the same key.
|
||||
return label.trim().toLowerCase().toUpperCase().toLowerCase();
|
||||
}
|
||||
|
||||
export function findClosingBracket(str: string, b: string) {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<p><a href="/foo">foo </a></p>
|
||||
<p><a href="/bar"> bar</a></p>
|
||||
<p><a href="/baz">baz</a></p>
|
||||
@@ -0,0 +1,9 @@
|
||||
[foo ]
|
||||
|
||||
[ bar]
|
||||
|
||||
[baz]
|
||||
|
||||
[foo]: /foo
|
||||
[bar]: /bar
|
||||
[baz ]: /baz
|
||||
Reference in New Issue
Block a user