-
Notifications
You must be signed in to change notification settings - Fork 96
fix(blob): normalize contentDisposition in copy() when addRandomSuffix is enabled #1045
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| '@vercel/blob': patch | ||
| --- | ||
|
|
||
| fix(blob): normalize contentDisposition filename in copy() when addRandomSuffix is enabled | ||
|
|
||
| When `copy()` is called with `addRandomSuffix: true`, the Vercel Blob API | ||
| returns a `contentDisposition` header containing the suffixed filename | ||
| (e.g. `attachment; filename="report-abc123.pdf"`). The SDK now normalizes | ||
| this to always use the original `toPathname` filename, matching the | ||
| behaviour already enforced for `put()`. | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,33 @@ import type { ClientCommonCreateBlobOptions } from './client'; | |||||||||||||||
| import type { CommonCreateBlobOptions } from './helpers'; | ||||||||||||||||
| import { BlobError, disallowedPathnameCharacters } from './helpers'; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Normalizes contentDisposition to use the original requested filename | ||||||||||||||||
| * instead of the API-returned pathname (which may include a random suffix). | ||||||||||||||||
| * This ensures `contentDisposition` always reflects the name the caller | ||||||||||||||||
| * provided, regardless of `addRandomSuffix` being enabled. | ||||||||||||||||
|
Comment on lines
+13
to
+15
|
||||||||||||||||
| * instead of the API-returned pathname (which may include a random suffix). | |
| * This ensures `contentDisposition` always reflects the name the caller | |
| * provided, regardless of `addRandomSuffix` being enabled. | |
| * instead of the API-returned pathname (which may include a random suffix), | |
| * when the header contains an exact quoted match for the response filename. | |
| * If no such quoted filename is present, the original contentDisposition | |
| * value is returned unchanged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changeset says the copy() normalization "matches the behaviour already enforced for
put()", butput()currently returnsresponse.contentDispositionunchanged (see packages/blob/src/put.ts). Either update the changeset wording to avoid claiming parity with put(), or update put() to use the same normalization helper so the statement is accurate.