From 01197896126c1b55766305dd169a89bf5fff2b8f Mon Sep 17 00:00:00 2001 From: GatsbyJS Bot Date: Fri, 4 Dec 2020 11:33:47 -0500 Subject: [PATCH] fix(gatsby-plugin-sharp): decode URL so it matches the cache key (#28449) (#28479) (cherry picked from commit 946eed0fb8cff37471d85a2b0d09f493e7e0442d) Co-authored-by: Kyle Mathews --- packages/gatsby-plugin-sharp/src/gatsby-node.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/gatsby-plugin-sharp/src/gatsby-node.js b/packages/gatsby-plugin-sharp/src/gatsby-node.js index 6c8cf490b7e49..fc1335a06966b 100644 --- a/packages/gatsby-plugin-sharp/src/gatsby-node.js +++ b/packages/gatsby-plugin-sharp/src/gatsby-node.js @@ -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 @@ -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) })