Skip to content

Commit

Permalink
fix(gatsby): Normalize paths for run queries before caching (gatsbyjs…
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews authored and mxxk committed Jun 21, 2019
1 parent 4f932ed commit dc6c1e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/gatsby/src/utils/normalize-page-path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This is a duplicate of the runtime util
// file cache-dir/normalize-page-path.js
module.exports = path => {
if (path === undefined) {
return path
}
if (path === `/`) {
return `/`
}
if (path.charAt(path.length - 1) === `/`) {
return path.slice(0, -1)
}
return path
}
2 changes: 2 additions & 0 deletions packages/gatsby/src/utils/websocket-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require(`path`)
const { store } = require(`../redux`)
const fs = require(`fs`)
const pageDataUtil = require(`../utils/page-data`)
const normalizePagePath = require(`../utils/normalize-page-path`)
const telemetry = require(`gatsby-telemetry`)
const url = require(`url`)
const { createHash } = require(`crypto`)
Expand Down Expand Up @@ -248,6 +249,7 @@ class WebsocketManager {
}

emitPageData(data: QueryResult) {
data.id = normalizePagePath(data.id)
this.pageResults.set(data.id, data)
if (this.isInitialised) {
this.websocket.send({ type: `pageQueryResult`, payload: data })
Expand Down

0 comments on commit dc6c1e0

Please sign in to comment.