Skip to content

Commit ce74f1b

Browse files
authored
fix(storage-vercel-blob): fixes issue where files with spaces in their name would not be retrieved correctly (#10062)
URI encodes filenames so that they're retrieved correctly from Vercel's blob storage. Sometimes spaces would cause problems only in certain file names
1 parent 605cf42 commit ce74f1b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/storage-vercel-blob/src/generateURL.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ type GenerateUrlArgs = {
99

1010
export const getGenerateUrl = ({ baseUrl }: GenerateUrlArgs): GenerateURL => {
1111
return ({ filename, prefix = '' }) => {
12-
return `${baseUrl}/${path.posix.join(prefix, filename)}`
12+
return `${baseUrl}/${path.posix.join(prefix, encodeURIComponent(filename))}`
1313
}
1414
}

packages/storage-vercel-blob/src/staticHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const getStaticHandler = (
1818
return async (req, { params: { filename } }) => {
1919
try {
2020
const prefix = await getFilePrefix({ collection, filename, req })
21-
const fileKey = path.posix.join(prefix, filename)
21+
const fileKey = path.posix.join(prefix, encodeURIComponent(filename))
2222

2323
const fileUrl = `${baseUrl}/${fileKey}`
2424
const etagFromHeaders = req.headers.get('etag') || req.headers.get('if-none-match')

0 commit comments

Comments
 (0)