Skip to content

Commit

Permalink
fix(gatsby-plugin-sharp): decode URL so it matches the cache key (#28449
Browse files Browse the repository at this point in the history
) (#28479)

(cherry picked from commit 946eed0)

Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
  • Loading branch information
GatsbyJS Bot and KyleAMathews committed Dec 4, 2020
1 parent 53502cc commit 0119789
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/gatsby-plugin-sharp/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ exports.onCreateDevServer = async ({ app, cache, reporter }) => {
finishProgressBar()

app.use(async (req, res, next) => {
const pathOnDisk = path.resolve(path.join(`./public/`, req.url))
const decodedURI = decodeURI(req.url)
const pathOnDisk = path.resolve(path.join(`./public/`, decodedURI))

if (await pathExists(pathOnDisk)) {
return res.sendFile(pathOnDisk)
}

const jobContentDigest = await cache.get(req.url)
const jobContentDigest = await cache.get(decodedURI)
const cacheResult = jobContentDigest
? await cache.get(jobContentDigest)
: null
Expand All @@ -80,7 +81,7 @@ exports.onCreateDevServer = async ({ app, cache, reporter }) => {
await _unstable_createJob(cacheResult, { reporter })
// we should implement cache.del inside our abstraction
await cache.cache.del(jobContentDigest)
await cache.cache.del(req.url)
await cache.cache.del(decodedURI)

return res.sendFile(pathOnDisk)
})
Expand Down

0 comments on commit 0119789

Please sign in to comment.