fix(build): apply `base` to links with download attribute (#5186)

pull/5189/head
/bin/cat 5 months ago committed by GitHub
parent c608981324
commit 01987c4c08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -30,8 +30,6 @@ export const linkPlugin = (
const hrefIndex = token.attrIndex('href') const hrefIndex = token.attrIndex('href')
if ( if (
hrefIndex >= 0 && hrefIndex >= 0 &&
token.attrIndex('target') < 0 &&
token.attrIndex('download') < 0 &&
token.attrGet('class') !== 'header-anchor' // header anchors are already normalized token.attrGet('class') !== 'header-anchor' // header anchors are already normalized
) { ) {
const hrefAttr = token.attrs![hrefIndex] const hrefAttr = token.attrs![hrefIndex]
@ -54,6 +52,9 @@ export const linkPlugin = (
!url.startsWith('#') && !url.startsWith('#') &&
// skip mail/custom protocol links // skip mail/custom protocol links
protocol.startsWith('http') && protocol.startsWith('http') &&
// skip links with target/download attribute as they are meant to be opened/downloaded as-is
token.attrIndex('target') < 0 &&
token.attrIndex('download') < 0 &&
// skip links to files (other than html/md) // skip links to files (other than html/md)
treatAsHtml(pathname) treatAsHtml(pathname)
) { ) {

Loading…
Cancel
Save