Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-plugin-sharp): decode URL so it matches the cache key (#28449) #28479

Merged
merged 1 commit into from
Dec 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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