From f5ff40abfa90f51b91db203a9fec46632aca28cd Mon Sep 17 00:00:00 2001 From: lohit Date: Wed, 8 Jan 2025 17:01:57 +0530 Subject: [PATCH] fix: file input element - missing path property (#3757) --- .../CollectionSettings/ClientCertSettings/index.js | 7 ++++--- .../bruno-app/src/components/Preferences/General/index.js | 5 ++++- packages/bruno-electron/src/preload.js | 6 +++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js index ba1debdec9..ccfac9046b 100644 --- a/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js @@ -68,12 +68,13 @@ const ClientCertSettings = ({ root, clientCertConfig, onUpdate, onRemove }) => { }); const getFile = (e) => { - if (e.files?.[0]?.path) { + const filePath = window?.ipcRenderer?.getFilePath(e?.files?.[0]); + if (filePath) { let relativePath; if (isWindowsOS()) { - relativePath = slash(path.win32.relative(root, e.files[0].path)); + relativePath = slash(path.win32.relative(root, filePath)); } else { - relativePath = path.posix.relative(root, e.files[0].path); + relativePath = path.posix.relative(root, filePath); } formik.setFieldValue(e.name, relativePath); } diff --git a/packages/bruno-app/src/components/Preferences/General/index.js b/packages/bruno-app/src/components/Preferences/General/index.js index 0d26c955d4..2867d9841e 100644 --- a/packages/bruno-app/src/components/Preferences/General/index.js +++ b/packages/bruno-app/src/components/Preferences/General/index.js @@ -90,7 +90,10 @@ const General = ({ close }) => { }; const addCaCertificate = (e) => { - formik.setFieldValue('customCaCertificate.filePath', e.target.files[0]?.path); + const filePath = window?.ipcRenderer?.getFilePath(e?.target?.files?.[0]); + if (filePath) { + formik.setFieldValue('customCaCertificate.filePath', filePath); + } }; const deleteCaCertificate = () => { diff --git a/packages/bruno-electron/src/preload.js b/packages/bruno-electron/src/preload.js index 4bfe2216bb..83dfcada81 100644 --- a/packages/bruno-electron/src/preload.js +++ b/packages/bruno-electron/src/preload.js @@ -1,4 +1,4 @@ -const { ipcRenderer, contextBridge } = require('electron'); +const { ipcRenderer, contextBridge, webUtils } = require('electron'); contextBridge.exposeInMainWorld('ipcRenderer', { invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args), @@ -10,5 +10,9 @@ contextBridge.exposeInMainWorld('ipcRenderer', { return () => { ipcRenderer.removeListener(channel, subscription); }; + }, + getFilePath (file) { + const path = webUtils.getPathForFile(file) + return path; } });