Skip to content
Merged
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
9 changes: 9 additions & 0 deletions packages/bruno-app/src/utils/codegenerator/auth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import get from 'lodash/get';

export const getAuthHeaders = (collectionRootAuth, requestAuth) => {

// Discovered edge case where code generation fails when you create a collection which has not been saved yet:
// Collection auth therefore null, and request inherits from collection, therefore it is also null
// TypeError: Cannot read properties of undefined (reading 'mode')
// at getAuthHeaders
if (!collectionRootAuth && !requestAuth) {
return [];
}

const auth = collectionRootAuth && ['inherit'].includes(requestAuth?.mode) ? collectionRootAuth : requestAuth;

switch (auth.mode) {
Expand Down
24 changes: 17 additions & 7 deletions packages/bruno-app/src/utils/codegenerator/har.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,25 @@ const createPostData = (body, type) => {
...(param.type === 'file' && { fileName: param.value })
}))
};
case 'file':
case 'file': {
const files = Array.isArray(body[body.mode]) ? body[body.mode] : [];
const selectedFile = files.find((param) => param.selected) || files[0];
const filePath = selectedFile?.filePath || '';
return {
mimeType: body[body.mode].filter((param) => param.enabled)[0].contentType,
params: body[body.mode]
.filter((param) => param.selected)
.map((param) => ({
value: param.filePath,
}))
mimeType: selectedFile?.contentType || 'application/octet-stream',
text: filePath,
params: filePath
? [
{
name: selectedFile?.name || 'file',
value: filePath,
fileName: filePath,
contentType: selectedFile?.contentType || 'application/octet-stream'
}
]
: []
};
}
default:
return {
mimeType: contentType,
Expand Down
Loading