From c09a719b7468a96e00f603e3149cd146e87ec14e Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Wed, 2 Dec 2020 13:39:49 -0800 Subject: [PATCH] fix(gatsby-plugin-sharp): decode URL so it matches the cache key --- 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) })