Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.

Commit 1f1fff8

Browse files
fix(page): page expects a router
to avoid a breaking change we need to support passing a router or a single route object
1 parent cd61e36 commit 1f1fff8

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/helpers.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ export function isRouteIgnored (name) {
6565
return config.ignoreRoutes.indexOf(name) !== -1
6666
}
6767

68-
export function isRoute (route) {
69-
// just check some random properties that we know
70-
// are inside the route object
71-
return route.query && route.params
68+
export function isRoute (data) {
69+
return data.query && data.params
70+
}
71+
72+
export function isRouter (data) {
73+
return data.currentRoute
7274
}

src/lib/page.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@ import {
66
getQueryString,
77
isRouteIgnored,
88
getRouteAnalytics,
9-
isRoute
9+
isRoute,
10+
isRouter
1011
} from '../helpers'
1112

1213
export default function page (...args) {
14+
let route
15+
16+
if (isRouter(args[0])) {
17+
route = args[0].currentRoute
18+
}
19+
1320
if (isRoute(args[0])) {
21+
route = args[0]
22+
}
23+
24+
if (route) {
1425
const { transformQueryString } = config.autoTracking
15-
const route = args[0]
1626
const queryString = getQueryString(route.query)
1727
const path = route.path + (transformQueryString ? queryString : '')
1828

0 commit comments

Comments
 (0)