Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions packages/bruno-cli/src/runner/prepare-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/bruno-cli/src/utils/form-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down