Skip to content

Commit e071e25

Browse files
authored
fix: fix non-breaking space in link url (#3667)
1 parent c37336c commit e071e25

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/rules.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ const tag = edit(
338338

339339
const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
340340

341-
const link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/)
341+
const link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/)
342342
.replace('label', _inlineLabel)
343-
.replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/)
343+
.replace('href', /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/)
344344
.replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/)
345345
.getRegex();
346346

test/specs/commonmark/commonmark.0.31.2.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -4056,8 +4056,7 @@
40564056
"example": 507,
40574057
"start_line": 7776,
40584058
"end_line": 7780,
4059-
"section": "Links",
4060-
"shouldFail": true
4059+
"section": "Links"
40614060
},
40624061
{
40634062
"markdown": "[link](/url \"title \"and\" title\")\n",

test/specs/gfm/commonmark.0.31.2.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -4056,8 +4056,7 @@
40564056
"example": 507,
40574057
"start_line": 7776,
40584058
"end_line": 7780,
4059-
"section": "Links",
4060-
"shouldFail": true
4059+
"section": "Links"
40614060
},
40624061
{
40634062
"markdown": "[link](/url \"title \"and\" title\")\n",

0 commit comments

Comments
 (0)