Skip to content

Commit f0a1a00

Browse files
committed
fix: handle links with encoded hash
1 parent 4480568 commit f0a1a00

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/markdown/link.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = md => {
1212
const link = token.attrs[hrefIndex]
1313
const href = link[1]
1414
const isExternal = /^https?:/.test(href)
15-
const isSourceLink = /(\/|\.md|\.html)(#[\w-]*)?$/.test(href)
15+
const isSourceLink = /(\/|\.md|\.html)(#.*)?$/.test(href)
1616
if (isExternal) {
1717
addAttr(token, 'target', '_blank')
1818
addAttr(token, 'rel', 'noopener noreferrer')
@@ -34,12 +34,13 @@ module.exports = md => {
3434

3535
to = to
3636
.replace(/\.md$/, '.html')
37-
.replace(/\.md(#[\w-]*)$/, '.html$1')
37+
.replace(/\.md(#.*)$/, '.html$1')
3838
// normalize links to README/index
3939
if (/^index|readme\.html/i.test(to)) {
4040
to = '/'
4141
}
42-
link[1] = to
42+
// markdown-it encodes the uri
43+
link[1] = decodeURI(to)
4344
return Object.assign({}, token, {
4445
tag: 'router-link'
4546
})

0 commit comments

Comments
 (0)