-
-
Couldn't load subscription status.
- Fork 415
fix: handle arrays properly in FormData #1431
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 4 commits
c1b22ef
e4c4bae
b9da1cd
6e854b8
abc99ef
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -113,14 +113,11 @@ export class HttpClient<SecurityDataType = unknown> { | |||||
|
|
||||||
| return Object.keys(input || {}).reduce((formData, key) => { | ||||||
| const property = input[key]; | ||||||
| formData.append( | ||||||
| key, | ||||||
| property instanceof Blob ? | ||||||
| property : | ||||||
| typeof property === "object" && property !== null ? | ||||||
| JSON.stringify(property) : | ||||||
| `${property}` | ||||||
| ); | ||||||
| const propertyContent = property instanceof Array ? property : [property]; | ||||||
|
|
||||||
| for (const formItem of propertyContent) { | ||||||
| formData.append(key, formItem instanceof Blob || typeof formItem === "string" ? formItem : JSON.stringify(formItem)); | ||||||
|
||||||
| formData.append(key, formItem instanceof Blob || typeof formItem === "string" ? formItem : JSON.stringify(formItem)); | |
| formData.append(key, formItem instanceof Blob ? formItem : `${formItem}`); |
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.
Bug: FormData Serialization Fails with BigInt and Undefined
The FormData serialization logic now uses JSON.stringify for non-Blob/non-string values, which introduces two issues. BigInt values now cause a TypeError. Also, undefined values are passed as the undefined primitive to formData.append(), relying on implicit browser conversion instead of the previous explicit string conversion, which may lead to unexpected behavior.
Uh oh!
There was an error while loading. Please reload this page.