Skip to content

Commit

Permalink
fix: getContentType function and save file logic update
Browse files Browse the repository at this point in the history
  • Loading branch information
therealrinku committed Feb 1, 2024
1 parent 72fde80 commit ed14e32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/bruno-app/src/utils/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ export const normalizeFileName = (name) => {
};

export const getContentType = (headers) => {
if (headers && headers.length) {
let contentType = headers
const headersArray = typeof headers === 'object' ? Object.entries(headers) : [];

if (headersArray.length > 0) {
let contentType = headersArray
.filter((header) => header[0].toLowerCase() === 'content-type')
.map((header) => {
return header[1];
Expand Down
6 changes: 4 additions & 2 deletions packages/bruno-electron/src/ipc/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,10 @@ const registerNetworkIpc = (mainWindow) => {
ipcMain.handle('renderer:save-response-to-file', async (event, response, url) => {
try {
const getHeaderValue = (headerName) => {
if (response.headers) {
const header = response.headers.find((header) => header[0] === headerName);
const headersArray = typeof response.headers === 'object' ? Object.entries(response.headers) : [];

if (headersArray.length > 0) {
const header = headersArray.find((header) => header[0] === headerName);
if (header && header.length > 1) {
return header[1];
}
Expand Down

0 comments on commit ed14e32

Please sign in to comment.