fix(theme): incorrect link external parsing (#396)
This commit is contained in:
parent
f21c42a3c7
commit
4e158964d2
@ -3,8 +3,6 @@ import { computed, type MaybeRefOrGetter, toValue } from 'vue'
|
||||
import { resolveRouteFullPath, useRoute } from 'vuepress/client'
|
||||
import { useData } from './data.js'
|
||||
|
||||
const ENDING_SLASH = /(?:\/|\.(?:md|html))$/i
|
||||
|
||||
export function useLink(
|
||||
href: MaybeRefOrGetter<string | undefined>,
|
||||
target?: MaybeRefOrGetter<string | undefined>,
|
||||
@ -19,8 +17,10 @@ export function useLink(
|
||||
return false
|
||||
if (rawTarget === '_blank' || isLinkExternal(link))
|
||||
return true
|
||||
const pathname = link.split(/[#?]/)[0]
|
||||
return !ENDING_SLASH.test(pathname)
|
||||
const filename = link.split(/[#?]/)[0]?.split('/').pop() || ''
|
||||
if (filename === '' || filename.endsWith('.html') || filename.endsWith('.md'))
|
||||
return false
|
||||
return filename.includes('.')
|
||||
})
|
||||
|
||||
const link = computed(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user