diff --git a/packages/bruno-app/src/components/RequestPane/FileBody/index.js b/packages/bruno-app/src/components/RequestPane/FileBody/index.js index 6929799f0b8..3c99ad7b928 100644 --- a/packages/bruno-app/src/components/RequestPane/FileBody/index.js +++ b/packages/bruno-app/src/components/RequestPane/FileBody/index.js @@ -9,6 +9,7 @@ import StyledWrapper from './StyledWrapper'; import FilePickerEditor from 'components/FilePickerEditor/index'; import SingleLineEditor from 'components/SingleLineEditor/index'; import MultiLineEditor from 'components/MultiLineEditor'; +import { normalizePath } from 'utils/common/path'; const FileBody = ({ item, collection }) => { const dispatch = useDispatch(); @@ -31,7 +32,7 @@ const FileBody = ({ item, collection }) => { const param = cloneDeep(_param); switch (type) { case 'filePath': { - param.filePath = e.target.filePath; + param.filePath = normalizePath(e.target.filePath); param.contentType = ''; break; } diff --git a/packages/bruno-app/src/components/RequestPane/MultipartFormParams/index.js b/packages/bruno-app/src/components/RequestPane/MultipartFormParams/index.js index 0f7cd4d3596..24cc9049023 100644 --- a/packages/bruno-app/src/components/RequestPane/MultipartFormParams/index.js +++ b/packages/bruno-app/src/components/RequestPane/MultipartFormParams/index.js @@ -68,7 +68,7 @@ const MultipartFormParams = ({ item, collection }) => { if (!Array.isArray(filePaths) || filePaths.length === 0) return; const processedPaths = filePaths.map((filePath) => { - return getRelativePathWithinBasePath(collection.pathname, filePath); + return getRelativePathWithinBasePath(collection.pathname, filePath, true); }); const currentParams = item.draft diff --git a/packages/bruno-cli/src/runner/prepare-request.js b/packages/bruno-cli/src/runner/prepare-request.js index 78d4c89f6d3..faf411d42ac 100644 --- a/packages/bruno-cli/src/runner/prepare-request.js +++ b/packages/bruno-cli/src/runner/prepare-request.js @@ -406,6 +406,11 @@ const prepareRequest = async (item = {}, collection = {}) => { axiosRequest.headers['content-type'] = contentType; if (filePath) { + // Normalize Windows separators when running on POSIX, without breaking UNC paths on Windows + if (path.sep === '/') { + filePath = filePath.replace(/\\/g, '/'); + } + filePath = path.normalize(filePath); if (!path.isAbsolute(filePath)) { filePath = path.join(collectionPath, filePath); } diff --git a/packages/bruno-cli/src/utils/form-data.js b/packages/bruno-cli/src/utils/form-data.js index 9bff10442a2..900ec76e616 100644 --- a/packages/bruno-cli/src/utils/form-data.js +++ b/packages/bruno-cli/src/utils/form-data.js @@ -26,6 +26,11 @@ const createFormData = (data, collectionPath) => { const filePaths = value || []; filePaths.forEach((filePath) => { let trimmedFilePath = filePath.trim(); + // Normalize Windows separators when running on POSIX, without breaking UNC paths on Windows + if (path.sep === '/') { + trimmedFilePath = trimmedFilePath.replace(/\\/g, '/'); + } + trimmedFilePath = path.normalize(trimmedFilePath); if (!path.isAbsolute(trimmedFilePath)) { trimmedFilePath = path.join(collectionPath, trimmedFilePath); }