Skip to content

Commit 946eed0

Browse files
authored
fix(gatsby-plugin-sharp): decode URL so it matches the cache key (#28449)
1 parent 5ffb6dd commit 946eed0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/gatsby-plugin-sharp/src/gatsby-node.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ exports.onCreateDevServer = async ({ app, cache, reporter }) => {
6262
finishProgressBar()
6363

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

6768
if (await pathExists(pathOnDisk)) {
6869
return res.sendFile(pathOnDisk)
6970
}
7071

71-
const jobContentDigest = await cache.get(req.url)
72+
const jobContentDigest = await cache.get(decodedURI)
7273
const cacheResult = jobContentDigest
7374
? await cache.get(jobContentDigest)
7475
: null
@@ -80,7 +81,7 @@ exports.onCreateDevServer = async ({ app, cache, reporter }) => {
8081
await _unstable_createJob(cacheResult, { reporter })
8182
// we should implement cache.del inside our abstraction
8283
await cache.cache.del(jobContentDigest)
83-
await cache.cache.del(req.url)
84+
await cache.cache.del(decodedURI)
8485

8586
return res.sendFile(pathOnDisk)
8687
})

0 commit comments

Comments
 (0)