diff --git a/lib/router/router.js b/lib/router/router.js index 5193be435b81..7529ee51f040 100644 --- a/lib/router/router.js +++ b/lib/router/router.js @@ -303,7 +303,7 @@ export default class Router { } urlIsNew (pathname, query) { - return this.pathname !== pathname || !shallowEquals(query, this.query) + return this.pathname !== pathname || !shallowEquals(query || {}, this.query || {}) } isShallowRoutingPossible (route) { diff --git a/test/unit/router.test.js b/test/unit/router.test.js index e9865d83e160..991323b32d9b 100644 --- a/test/unit/router.test.js +++ b/test/unit/router.test.js @@ -63,4 +63,14 @@ describe('Router', () => { expect(Object.keys(pageLoader.loaded)).toEqual(routes) }) }) + + describe('.urlIsNew()', () => { + it('should handle undefined starting query parameters', () => { + const pageLoader = new PageLoader() + const router = new Router('/', undefined, '/', { pageLoader }) + // This function will call shallowEqual with the query below and the undefined value set in + // the constructor. + router.urlIsNew('/', { queryVariable: '1' }) + }) + }) })