@@ -7,6 +7,7 @@ import ReactDOM from "react-dom"
77import { Router , Route , withRouter , matchPath } from "react-router-dom"
88import { ScrollContext } from "gatsby-react-router-scroll"
99import domReady from "domready"
10+ import { createLocation } from "history"
1011import history from "./history"
1112window . ___history = history
1213import emitter from "./emitter"
@@ -50,7 +51,9 @@ apiRunnerAsync(`onClientEntry`).then(() => {
5051 require ( `./register-service-worker` )
5152 }
5253
53- const navigateTo = pathname => {
54+ const navigateTo = to => {
55+ const location = createLocation ( to , null , null , history . location )
56+ let { pathname } = location
5457 const redirect = redirectMap [ pathname ]
5558
5659 // If we're redirecting, just replace the passed in pathname
@@ -70,7 +73,7 @@ apiRunnerAsync(`onClientEntry`).then(() => {
7073 if ( e . page . path === loader . getPage ( pathname ) . path ) {
7174 emitter . off ( `onPostLoadPageResources` , eventHandler )
7275 clearTimeout ( timeoutId )
73- window . ___history . push ( pathname )
76+ window . ___history . push ( location )
7477 }
7578 }
7679
@@ -79,13 +82,13 @@ apiRunnerAsync(`onClientEntry`).then(() => {
7982 const timeoutId = setTimeout ( ( ) => {
8083 emitter . off ( `onPostLoadPageResources` , eventHandler )
8184 emitter . emit ( `onDelayedLoadPageResources` , { pathname } )
82- window . ___history . push ( pathname )
85+ window . ___history . push ( location )
8386 } , 1000 )
8487
8588 if ( loader . getResourcesForPathname ( pathname ) ) {
8689 // The resources are already loaded so off we go.
8790 clearTimeout ( timeoutId )
88- window . ___history . push ( pathname )
91+ window . ___history . push ( location )
8992 } else {
9093 // They're not loaded yet so let's add a listener for when
9194 // they finish loading.
0 commit comments