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

Commit

Permalink
fix(page): page expects a router
Browse files Browse the repository at this point in the history
to avoid a breaking change we need to support passing a router or a single route object
  • Loading branch information
MatteoGabriele committed Nov 2, 2017
1 parent cd61e36 commit 1f1fff8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ export function isRouteIgnored (name) {
return config.ignoreRoutes.indexOf(name) !== -1
}

export function isRoute (route) {
// just check some random properties that we know
// are inside the route object
return route.query && route.params
export function isRoute (data) {
return data.query && data.params
}

export function isRouter (data) {
return data.currentRoute
}
14 changes: 12 additions & 2 deletions src/lib/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ import {
getQueryString,
isRouteIgnored,
getRouteAnalytics,
isRoute
isRoute,
isRouter
} from '../helpers'

export default function page (...args) {
let route

if (isRouter(args[0])) {
route = args[0].currentRoute
}

if (isRoute(args[0])) {
route = args[0]
}

if (route) {
const { transformQueryString } = config.autoTracking
const route = args[0]
const queryString = getQueryString(route.query)
const path = route.path + (transformQueryString ? queryString : '')

Expand Down

0 comments on commit 1f1fff8

Please sign in to comment.