mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-27 14:44:07 +00:00
Feat: Support multipart/mixed (#7155)
* feat(): support multipart mixed fix: support vars interpolation on mixed multi-part Update packages/bruno-electron/src/ipc/network/interpolate-vars.js Co-authored-by: Timon <39559178+Its-treason@users.noreply.github.com> refactor: use startsWith feat: best effort for other multipart/* contentypes * feat: enhance variable interpolation for multipart requests - Updated `interpolateVars` function to support interpolation in multipart/form-data and multipart/mixed requests. - Added handling for empty multipart arrays and parts with missing or undefined values. - Improved type checks for content types to ensure proper interpolation behavior. Includes new tests to validate the interpolation functionality for multipart requests. * fix: normalize error handling in sendRequest and improve test reliability --------- Co-authored-by: Alfonso Presa <alfonso-presa@users.noreply.github.com>
This commit is contained in:
@@ -471,20 +471,26 @@ const addBruShimToContext = (vm, bru) => {
|
||||
bruObject.dispose();
|
||||
|
||||
vm.evalCode(`
|
||||
// sendRequest with callback: normalize error.status (axios uses error.response.status) so
|
||||
// tests like expect(error.status).to.eql(404) pass in safe sandbox; return response after
|
||||
// success callback for consistent promise resolution.
|
||||
globalThis.bru.sendRequest = async (requestConfig, callback) => {
|
||||
if (!callback) return await globalThis.bru._sendRequest(requestConfig);
|
||||
try {
|
||||
const response = await globalThis.bru._sendRequest(requestConfig);
|
||||
try {
|
||||
await callback(null, response);
|
||||
return response;
|
||||
}
|
||||
catch(error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
catch(error) {
|
||||
const errObj = JSON.parse(JSON.stringify(error));
|
||||
if (errObj && errObj.response && typeof errObj.response.status === 'number') errObj.status = errObj.response.status;
|
||||
try {
|
||||
await callback(JSON.parse(JSON.stringify(error)), null);
|
||||
await callback(errObj, null);
|
||||
}
|
||||
catch(err) {
|
||||
return Promise.reject(err);
|
||||
|
||||
Reference in New Issue
Block a user