Skip to content

Commit

Permalink
fix(theme): incorrect link external parsing (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo authored Dec 23, 2024
1 parent f21c42a commit 4e15896
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions theme/src/client/composables/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -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(() => {
Expand Down

0 comments on commit 4e15896

Please sign in to comment.