File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,10 @@ export type {
16
16
17
17
export const EXTERNAL_URL_RE = / ^ (?: [ a - z ] + : | \/ \/ ) / i
18
18
export const APPEARANCE_KEY = 'vitepress-theme-appearance'
19
- export const HASH_RE = / # .* $ /
20
- export const EXT_RE = / ( i n d e x ) ? \. ( m d | h t m l ) $ /
19
+
20
+ const HASH_RE = / # .* $ /
21
+ const HASH_OR_QUERY_RE = / [ ? # ] .* $ /
22
+ const INDEX_OR_EXT_RE = / (?: ( ^ | \/ ) i n d e x ) ? \. (?: m d | h t m l ) $ /
21
23
22
24
export const inBrowser = typeof document !== 'undefined'
23
25
@@ -60,8 +62,10 @@ export function isActive(
60
62
return true
61
63
}
62
64
63
- export function normalize ( path : string ) : string {
64
- return decodeURI ( path ) . replace ( HASH_RE , '' ) . replace ( EXT_RE , '' )
65
+ function normalize ( path : string ) : string {
66
+ return decodeURI ( path )
67
+ . replace ( HASH_OR_QUERY_RE , '' )
68
+ . replace ( INDEX_OR_EXT_RE , '$1' )
65
69
}
66
70
67
71
export function isExternal ( path : string ) : boolean {
You can’t perform that action at this time.
0 commit comments