fix(theme): correctly normalize paths ending with "index"

pull/3544/head
yhzx233 2 years ago
parent 67a9964c4e
commit f2a35af604

@ -17,7 +17,8 @@ export type {
export const EXTERNAL_URL_RE = /^(?:[a-z]+:|\/\/)/i
export const APPEARANCE_KEY = 'vitepress-theme-appearance'
export const HASH_RE = /#.*$/
export const EXT_RE = /(index)?\.(md|html)$/
export const EXT_RE = /\.(md|html)$/
export const INDEX_RE = /\/index$/
export const inBrowser = typeof document !== 'undefined'
@ -61,7 +62,7 @@ export function isActive(
}
export function normalize(path: string): string {
return decodeURI(path).replace(HASH_RE, '').replace(EXT_RE, '')
return decodeURI(path).replace(HASH_RE, '').replace(EXT_RE, '').replace(INDEX_RE, '/')
}
export function isExternal(path: string): boolean {

Loading…
Cancel
Save