Skip to content

Commit aef5cce

Browse files
committed
Fix to not escape in autolinks
1 parent 55a0476 commit aef5cce

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/handle/link.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = link
22
link.peek = linkPeek
33

4+
var toString = require('mdast-util-to-string')
45
var checkQuote = require('../util/check-quote')
56
var formatLinkAsAutolink = require('../util/format-link-as-autolink')
67
var phrasing = require('../util/container-phrasing')
@@ -21,7 +22,7 @@ function link(node, _, context) {
2122
currentStack = context.stack
2223
context.stack = []
2324
exit = context.enter('autolink')
24-
value = '<' + phrasing(node, context, {before: '<', after: '>'}) + '>'
25+
value = '<' + toString(node) + '>'
2526
exit()
2627
context.stack = currentStack
2728
return value

test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,5 +2459,13 @@ test('roundtrip', function (t) {
24592459

24602460
t.equal(to(from(doc)), doc, 'should roundtrip spread items in sublists (3)')
24612461

2462+
doc = 'An autolink: <http://example.com/?foo=1&bar=2>.\n'
2463+
2464+
t.equal(
2465+
to(from(doc)),
2466+
doc,
2467+
'should roundtrip autolinks w/ potentially escapable characters'
2468+
)
2469+
24622470
t.end()
24632471
})

0 commit comments

Comments
 (0)