@ -36,15 +36,22 @@ export const linkPlugin = (
pushLink ( url , env )
pushLink ( url , env )
}
}
hrefAttr [ 1 ] = url . replace ( PATHNAME_PROTOCOL_RE , '' )
hrefAttr [ 1 ] = url . replace ( PATHNAME_PROTOCOL_RE , '' )
} else if (
} else {
// internal anchor links
if (
! url . startsWith ( '#' ) &&
// internal anchor links
// mail links
! url . startsWith ( '#' ) &&
! url . startsWith ( 'mailto:' ) &&
// mail links
// links to files (other than html/md)
! url . startsWith ( 'mailto:' ) &&
! /\.(?!html|md)\w+($|\?)/i . test ( url )
// links to files (other than html/md)
) {
! /\.(?!html|md)\w+($|\?)/i . test ( url )
normalizeHref ( hrefAttr , env )
) {
normalizeHref ( hrefAttr , env )
}
// append base to internal (non-relative) urls
if ( hrefAttr [ 1 ] . startsWith ( '/' ) ) {
hrefAttr [ 1 ] = ` ${ base } ${ hrefAttr [ 1 ] } ` . replace ( /\/+/g , '/' )
}
}
}
// encode vite-specific replace strings in case they appear in URLs
// encode vite-specific replace strings in case they appear in URLs
@ -90,11 +97,6 @@ export const linkPlugin = (
// export it for existence check
// export it for existence check
pushLink ( url . replace ( /\.html$/ , '' ) , env )
pushLink ( url . replace ( /\.html$/ , '' ) , env )
// append base to internal (non-relative) urls
if ( url . startsWith ( '/' ) ) {
url = ` ${ base } ${ url } ` . replace ( /\/+/g , '/' )
}
// markdown-it encodes the uri
// markdown-it encodes the uri
hrefAttr [ 1 ] = decodeURI ( url )
hrefAttr [ 1 ] = decodeURI ( url )
}
}