File tree 3 files changed +39
-2
lines changed
packages/client/src/router
3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change
1
+ <button id="home" @click ="goHome">Home</button >
2
+ <button id="404" @click ="go404">404</button >
3
+
4
+ <script setup lang =" ts " >
5
+ import { useRouter } from ' vuepress/client' ;
6
+
7
+ const router = useRouter ();
8
+
9
+ const goHome = () => {
10
+ router .push (' /?home=true' );
11
+ }
12
+
13
+ const go404 = () => {
14
+ router .push (' /404.html#404' );
15
+ }
16
+ </script >
Original file line number Diff line number Diff line change
1
+ it ( 'should preserve query' , ( ) => {
2
+ const E2E_BASE = Cypress . env ( 'E2E_BASE' )
3
+
4
+ cy . visit ( '/router/navigation.html' )
5
+
6
+ cy . get ( '#home' ) . click ( )
7
+
8
+ cy . location ( 'pathname' ) . should ( 'eq' , E2E_BASE )
9
+ cy . location ( 'search' ) . should ( 'eq' , '?home=true' )
10
+ } )
11
+
12
+ it ( 'should preserve hash' , ( ) => {
13
+ const E2E_BASE = Cypress . env ( 'E2E_BASE' )
14
+
15
+ cy . visit ( '/router/navigation.html' )
16
+
17
+ cy . get ( '#404' ) . click ( )
18
+
19
+ cy . location ( 'pathname' ) . should ( 'eq' , `${ E2E_BASE } 404.html` )
20
+ cy . location ( 'hash' ) . should ( 'eq' , '#404' )
21
+ } )
Original file line number Diff line number Diff line change @@ -40,9 +40,9 @@ export const createVueRouter = (): Router => {
40
40
// and save page data to route meta
41
41
router . beforeResolve ( async ( to , from ) : Promise < string | void > => {
42
42
if ( to . path !== from . path || from === START_LOCATION ) {
43
- const route = resolveRoute ( to . path )
43
+ const route = resolveRoute ( to . fullPath )
44
44
45
- if ( route . path !== to . path ) {
45
+ if ( route . path !== to . fullPath ) {
46
46
return route . path
47
47
}
48
48
const pageChunk = await route . loader ( )
You can’t perform that action at this time.
0 commit comments