mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(Webhook Node): Backward compatible form-data parsing for non-array files (#7385)
Fixes https://community.n8n.io/t/possible-bug-0-added-to-end-of-files-sent-via-webhook/31169
This commit is contained in:
committed by
GitHub
parent
7ed466db7f
commit
6479eb180f
@@ -116,20 +116,21 @@ describe('Webhook API', () => {
|
||||
.field('field1', 'value1')
|
||||
.field('field2', 'value2')
|
||||
.field('field2', 'value3')
|
||||
.attach('file', Buffer.from('random-text'))
|
||||
.attach('file1', Buffer.from('random-text'))
|
||||
.attach('file2', Buffer.from('random-text'))
|
||||
.attach('file2', Buffer.from('random-text'))
|
||||
.set('content-type', 'multipart/form-data');
|
||||
|
||||
expect(response.statusCode).toEqual(200);
|
||||
expect(response.body.type).toEqual('multipart/form-data');
|
||||
const {
|
||||
data,
|
||||
files: {
|
||||
file: [file],
|
||||
},
|
||||
} = response.body.body;
|
||||
const { data, files } = response.body.body;
|
||||
expect(data).toEqual({ field1: 'value1', field2: ['value2', 'value3'] });
|
||||
expect(file.mimetype).toEqual('application/octet-stream');
|
||||
expect(readFileSync(file.filepath, 'utf-8')).toEqual('random-text');
|
||||
|
||||
expect(files.file1).not.toBeInstanceOf(Array);
|
||||
expect(files.file1.mimetype).toEqual('application/octet-stream');
|
||||
expect(readFileSync(files.file1.filepath, 'utf-8')).toEqual('random-text');
|
||||
expect(files.file2).toBeInstanceOf(Array);
|
||||
expect(files.file2.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user