From f2a35af6042d1d7f0d352d5e59e1aad8eb51e50a Mon Sep 17 00:00:00 2001 From: yhzx233 <2058777361@qq.com> Date: Mon, 5 Feb 2024 23:08:24 +0800 Subject: [PATCH] fix(theme): correctly normalize paths ending with "index" --- src/shared/shared.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shared/shared.ts b/src/shared/shared.ts index ea5d2cb9..e470825e 100644 --- a/src/shared/shared.ts +++ b/src/shared/shared.ts @@ -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 {