Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Libraries/Network/FormData.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class FormData {
// an object with a `uri` attribute. Optionally, it can also
// have a `name` and `type` attribute to specify filename and
// content type (cf. web Blob interface.)
if (typeof value === 'object' && value) {
if (typeof value === 'object' && !Array.isArray(value) && value) {
if (typeof value.name === 'string') {
headers['content-disposition'] += '; filename="' + value.name + '"';
}
Expand Down
22 changes: 22 additions & 0 deletions Libraries/Network/__tests__/FormData-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,26 @@ describe('FormData', function () {
};
expect(formData.getParts()[0]).toMatchObject(expectedPart);
});

it('should return non blob array', function () {
formData.append('array', [
true,
false,
undefined,
null,
{},
[],
'string',
0,
]);

const expectedPart = {
string: 'true,false,,,[object Object],,string,0',
headers: {
'content-disposition': 'form-data; name="array"',
},
fieldName: 'array',
};
expect(formData.getParts()[0]).toMatchObject(expectedPart);
});
});