diff --git a/packages/storage-vercel-blob/src/generateURL.ts b/packages/storage-vercel-blob/src/generateURL.ts index fcd3ae98f08..5a87e95570a 100644 --- a/packages/storage-vercel-blob/src/generateURL.ts +++ b/packages/storage-vercel-blob/src/generateURL.ts @@ -9,6 +9,6 @@ type GenerateUrlArgs = { export const getGenerateUrl = ({ baseUrl }: GenerateUrlArgs): GenerateURL => { return ({ filename, prefix = '' }) => { - return `${baseUrl}/${path.posix.join(prefix, filename)}` + return `${baseUrl}/${path.posix.join(prefix, encodeURIComponent(filename))}` } } diff --git a/packages/storage-vercel-blob/src/staticHandler.ts b/packages/storage-vercel-blob/src/staticHandler.ts index 107a887804e..aa2743fd7c5 100644 --- a/packages/storage-vercel-blob/src/staticHandler.ts +++ b/packages/storage-vercel-blob/src/staticHandler.ts @@ -18,7 +18,7 @@ export const getStaticHandler = ( return async (req, { params: { filename } }) => { try { const prefix = await getFilePrefix({ collection, filename, req }) - const fileKey = path.posix.join(prefix, filename) + const fileKey = path.posix.join(prefix, encodeURIComponent(filename)) const fileUrl = `${baseUrl}/${fileKey}` const etagFromHeaders = req.headers.get('etag') || req.headers.get('if-none-match')