fix: getContentType function and save file logic update (#1499)

This commit is contained in:
Rinku Chaudhari 2024-02-01 13:44:06 +05:45 committed by GitHub
parent 72fde80577
commit 7b6c72c63b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -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];

View File

@ -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];
}