diff --git a/packages/gatsby-link/src/__tests__/index.js b/packages/gatsby-link/src/__tests__/index.js index ac2507c6a1229..197609d21fbf6 100644 --- a/packages/gatsby-link/src/__tests__/index.js +++ b/packages/gatsby-link/src/__tests__/index.js @@ -32,13 +32,13 @@ const getReplace = () => { } const getWithPrefix = (pathPrefix = ``) => { - Object.assign(global.window, { - __PATH_PREFIX__: pathPrefix, - }) + global.__PATH_PREFIX__ = pathPrefix + return withPrefix } const setup = ({ sourcePath = `/active`, linkProps } = {}) => { + global.__PATH_PREFIX__ = `` const source = createMemorySource(sourcePath) const history = createHistory(source) diff --git a/packages/gatsby-link/src/index.js b/packages/gatsby-link/src/index.js index ecdfa7eeab9d4..cbbf2aa4b3953 100644 --- a/packages/gatsby-link/src/index.js +++ b/packages/gatsby-link/src/index.js @@ -108,9 +108,11 @@ class GatsbyLink extends React.Component { ...rest } = this.props + const prefixTo = withPrefix(to) + return ( { const bodyComponent = createElement( ServerLocation, - { url: pagePath }, - createElement(Router, null, createElement(RouteHandler, { path: `/*` })) + { url: `${pathPrefix}${pagePath}` }, + createElement(Router, + { + baseuri: pathPrefix.slice(0, -1), + }, + createElement(RouteHandler, { path: `/*` }) + ) ) // Let the site or plugin render the page component. diff --git a/packages/gatsby/src/redux/index.js b/packages/gatsby/src/redux/index.js index 05a82715f6808..0198062671108 100644 --- a/packages/gatsby/src/redux/index.js +++ b/packages/gatsby/src/redux/index.js @@ -49,9 +49,6 @@ try { initialState.nodes = objectToMap(initialState.nodes) } } catch (e) { - if (process.env.NODE_ENV === `test`) { - console.log(`error loading initialState`, e) - } // ignore errors. }