use request directory as the destination for saving response (#5699)

* use request directory as the destination for saving response
* use request directory as the destination for saving response
This commit is contained in:
Andrii Oriekhov
2025-10-04 00:03:28 +03:00
committed by GitHub
parent 239f1dc9f5
commit 3fa9fea6a4
2 changed files with 4 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ const ResponseSave = ({ item }) => {
const saveResponseToFile = () => {
return new Promise((resolve, reject) => {
ipcRenderer
.invoke('renderer:save-response-to-file', response, item?.requestSent?.url)
.invoke('renderer:save-response-to-file', response, item?.requestSent?.url, item.pathname)
.then(resolve)
.catch((err) => {
toast.error(get(err, 'error.message') || 'Something went wrong!');

View File

@@ -1421,7 +1421,7 @@ const registerNetworkIpc = (mainWindow) => {
);
// save response to file
ipcMain.handle('renderer:save-response-to-file', async (event, response, url) => {
ipcMain.handle('renderer:save-response-to-file', async (event, response, url, pathname) => {
try {
const getHeaderValue = (headerName) => {
const headersArray = typeof response.headers === 'object' ? Object.entries(response.headers) : [];
@@ -1467,8 +1467,9 @@ const registerNetworkIpc = (mainWindow) => {
);
};
const dirPath = path.dirname(pathname);
const fileName = determineFileName();
const filePath = await chooseFileToSave(mainWindow, fileName);
const filePath = await chooseFileToSave(mainWindow, path.join(dirPath, fileName));
if (filePath) {
const encoding = getEncodingFormat();
const data = Buffer.from(response.dataBuffer, 'base64')