Skip to content

Commit

Permalink
fix(storage-vercel-blob): fixes issue where files with spaces in thei…
Browse files Browse the repository at this point in the history
…r 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
  • Loading branch information
paulpopus authored Dec 19, 2024
1 parent 605cf42 commit ce74f1b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/storage-vercel-blob/src/generateURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))}`
}
}
2 changes: 1 addition & 1 deletion packages/storage-vercel-blob/src/staticHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit ce74f1b

Please sign in to comment.