Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/gatsby-link/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 5 additions & 3 deletions packages/gatsby-link/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ class GatsbyLink extends React.Component {
...rest
} = this.props

const prefixTo = withPrefix(to)

return (
<Link
to={to}
to={prefixTo}
state={state}
getProps={getProps}
innerRef={this.handleRef}
Expand All @@ -135,7 +137,7 @@ class GatsbyLink extends React.Component {
e.preventDefault()
// Is this link pointing to a hash on the same page? If so,
// just scroll there.
const { pathname, hash } = parsePath(to)
const { pathname, hash } = parsePath(prefixTo)
if (pathname === location.pathname || !pathname) {
const element = hash
? document.getElementById(hash.substr(1))
Expand All @@ -151,7 +153,7 @@ class GatsbyLink extends React.Component {

// Make sure the necessary scripts and data are
// loaded before continuing.
push(to)
push(prefixTo)
}

return true
Expand Down
9 changes: 7 additions & 2 deletions packages/gatsby/cache-dir/static-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ export default (pagePath, callback) => {

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.
Expand Down
3 changes: 0 additions & 3 deletions packages/gatsby/src/redux/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

Expand Down