mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 22:45:25 +00:00
Merge branch 'usebruno:main' into handle-invalid-auth-in-pm-export
This commit is contained in:
@@ -20,14 +20,14 @@ const formatResponse = (data, mode, filter) => {
|
||||
}
|
||||
|
||||
if (data === null) {
|
||||
return data;
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (mode.includes('json')) {
|
||||
let isValidJSON = false;
|
||||
|
||||
try {
|
||||
isValidJSON = typeof JSON.parse(JSON.stringify(data)) === 'object';
|
||||
isValidJSON = typeof JSON.parse(JSON.stringify(data)) === 'object'
|
||||
} catch (error) {
|
||||
console.log('Error parsing JSON: ', error.message);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ export const globalEnvironmentsUpdateEvent = ({ globalEnvironmentVariables }) =>
|
||||
// update existing values
|
||||
variables = variables?.map?.(variable => ({
|
||||
...variable,
|
||||
value: stringifyIfNot(globalEnvironmentVariables?.[variable?.name])
|
||||
value: globalEnvironmentVariables?.[variable?.name]
|
||||
}));
|
||||
|
||||
// add new env values
|
||||
@@ -201,7 +201,7 @@ export const globalEnvironmentsUpdateEvent = ({ globalEnvironmentVariables }) =>
|
||||
variables.push({
|
||||
uid: uuid(),
|
||||
name: key,
|
||||
value: stringifyIfNot(value),
|
||||
value,
|
||||
type: 'text',
|
||||
secret: false,
|
||||
enabled: true
|
||||
|
||||
@@ -797,7 +797,7 @@ export const getGlobalEnvironmentVariables = ({ globalEnvironments, activeGlobal
|
||||
const environment = globalEnvironments?.find(env => env?.uid === activeGlobalEnvironmentUid);
|
||||
if (environment) {
|
||||
each(environment.variables, (variable) => {
|
||||
if (variable.name && variable.value && variable.enabled) {
|
||||
if (variable.name && variable.enabled) {
|
||||
variables[variable.name] = variable.value;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ function getDataString(request) {
|
||||
console.error('Failed to parse JSON data:', error);
|
||||
return { data: request.data.toString() };
|
||||
}
|
||||
} else if (contentType && contentType.includes('application/xml')) {
|
||||
} else if (contentType && (contentType.includes('application/xml') || contentType.includes('text/plain'))) {
|
||||
return { data: request.data };
|
||||
}
|
||||
|
||||
@@ -174,14 +174,14 @@ const curlToJson = (curlCommand) => {
|
||||
}
|
||||
|
||||
if (request.auth) {
|
||||
if(request.auth.mode === 'basic'){
|
||||
if (request.auth.mode === 'basic') {
|
||||
requestJson.auth = {
|
||||
mode: 'basic',
|
||||
basic: {
|
||||
username: repr(request.auth.basic?.username),
|
||||
password: repr(request.auth.basic?.password)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,9 +79,9 @@ export const transformItemsInCollection = (collection) => {
|
||||
// from 5 feb 2024, multipartFormData needs to have a type
|
||||
// this was introduced when we added support for file uploads
|
||||
// below logic is to make older collection exports backward compatible
|
||||
let multipartFormData = _.get(item, 'request.body.multipartForm');
|
||||
let multipartFormData = get(item, 'request.body.multipartForm');
|
||||
if (multipartFormData) {
|
||||
_.each(multipartFormData, (form) => {
|
||||
each(multipartFormData, (form) => {
|
||||
if (!form.type) {
|
||||
form.type = 'text';
|
||||
}
|
||||
|
||||
@@ -136,8 +136,7 @@ const prepareRequest = (item = {}, collection = {}) => {
|
||||
if (request.body.mode === 'multipartForm') {
|
||||
axiosRequest.headers['content-type'] = 'multipart/form-data';
|
||||
const enabledParams = filter(request.body.multipartForm, (p) => p.enabled);
|
||||
const collectionPath = process.cwd();
|
||||
axiosRequest.data = createFormData(enabledParams, collectionPath);
|
||||
axiosRequest.data = enabledParams;
|
||||
}
|
||||
|
||||
if (request.body.mode === 'graphql') {
|
||||
|
||||
@@ -349,10 +349,10 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
// rename item
|
||||
ipcMain.handle('renderer:rename-item', async (event, oldPath, newPath, newName) => {
|
||||
const tempDir = path.join(os.tmpdir(), `temp-folder-${Date.now()}`);
|
||||
const parentDir = path.dirname(oldPath);
|
||||
const isWindowsOSAndNotWSLAndItemHasSubDirectories = isWindowsOS() && !isWSLPath(oldPath) && hasSubDirectories(oldPath);
|
||||
let parentDirUnwatched = false;
|
||||
let parentDirRewatched = false;
|
||||
// const parentDir = path.dirname(oldPath);
|
||||
const isWindowsOSAndNotWSLAndItemHasSubDirectories = isDirectory(oldPath) && isWindowsOS() && !isWSLPath(oldPath) && hasSubDirectories(oldPath);
|
||||
// let parentDirUnwatched = false;
|
||||
// let parentDirRewatched = false;
|
||||
|
||||
try {
|
||||
// Normalize paths if they are WSL paths
|
||||
@@ -376,8 +376,8 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
moveRequestUid(bruFile, newBruFilePath);
|
||||
}
|
||||
|
||||
watcher.unlinkItemPathInWatcher(parentDir);
|
||||
parentDirUnwatched = true;
|
||||
// watcher.unlinkItemPathInWatcher(parentDir);
|
||||
// parentDirUnwatched = true;
|
||||
|
||||
/**
|
||||
* If it is windows OS
|
||||
@@ -396,8 +396,8 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
} else {
|
||||
await fs.renameSync(oldPath, newPath);
|
||||
}
|
||||
watcher.addItemPathInWatcher(parentDir);
|
||||
parentDirRewatched = true;
|
||||
// watcher.addItemPathInWatcher(parentDir);
|
||||
// parentDirRewatched = true;
|
||||
|
||||
return newPath;
|
||||
}
|
||||
@@ -424,9 +424,9 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
} catch (error) {
|
||||
// in case an error occurs during the rename file operations after unlinking the parent dir
|
||||
// and the rewatch fails, we need to add it back to watcher
|
||||
if (parentDirUnwatched && !parentDirRewatched) {
|
||||
watcher.addItemPathInWatcher(parentDir);
|
||||
}
|
||||
// if (parentDirUnwatched && !parentDirRewatched) {
|
||||
// watcher.addItemPathInWatcher(parentDir);
|
||||
// }
|
||||
|
||||
// in case the rename file operations fails, and we see that the temp dir exists
|
||||
// and the old path does not exist, we need to restore the data from the temp dir to the old path
|
||||
|
||||
@@ -365,11 +365,15 @@ const parseDataFromResponse = (response, disableParsingResponseJson = false) =>
|
||||
try {
|
||||
// Filter out ZWNBSP character
|
||||
// https://gist.github.com/antic183/619f42b559b78028d1fe9e7ae8a1352d
|
||||
|
||||
// If the response is a string and starts and ends with double quotes, it's a stringified JSON and should not be parsed
|
||||
data = data.replace(/^\uFEFF/, '');
|
||||
if (!disableParsingResponseJson) {
|
||||
if ( !disableParsingResponseJson && ! (typeof data === 'string' && data.startsWith("\"") && data.endsWith("\""))) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
} catch { }
|
||||
} catch {
|
||||
console.log('Failed to parse response data as JSON');
|
||||
}
|
||||
|
||||
return { data, dataBuffer };
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ post {
|
||||
}
|
||||
|
||||
body:multipart-form {
|
||||
foo: {"bar":"baz"} @contentType(application/json--test)
|
||||
form-data-key: {{form-data-key}}
|
||||
form-data-stringified-object: {{form-data-stringified-object}}
|
||||
file: @file(bruno.png)
|
||||
@@ -19,6 +20,7 @@ body:multipart-form {
|
||||
assert {
|
||||
res.body: contains form-data-value
|
||||
res.body: contains {"foo":123}
|
||||
res.body: contains Content-Type: application/json--test
|
||||
}
|
||||
|
||||
script:pre-request {
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
meta {
|
||||
name: mixed-content-types
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{host}}/api/multipart/mixed-content-types
|
||||
body: multipartForm
|
||||
auth: none
|
||||
}
|
||||
|
||||
body:multipart-form {
|
||||
param1: test
|
||||
param2: {"test":"i am json"} @contentType(application/json)
|
||||
param3: @file(multipart/small.png)
|
||||
}
|
||||
|
||||
assert {
|
||||
res.status: eq 200
|
||||
res.body.find(p=>p.name === 'param1').contentType: isUndefined
|
||||
res.body.find(p=>p.name === 'param2').contentType: eq application/json
|
||||
res.body.find(p=>p.name === 'param3').contentType: eq image/png
|
||||
}
|
||||
Reference in New Issue
Block a user