mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-30 08:04:09 +00:00
fix(bru-2035): form-urlencoded logic updates (#5820)
This commit is contained in:
@@ -3,24 +3,6 @@ const FormData = require('form-data');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* @param {Array.<object>} params The request body Array
|
||||
* @returns {string} Returns a order respecting standard compliant string of form encoded values
|
||||
*/
|
||||
const buildFormUrlEncodedPayload = (params) => {
|
||||
if (typeof params !== 'object') return '';
|
||||
if (!Array.isArray(params)) return '';
|
||||
const resultParams = new URLSearchParams();
|
||||
for (const param of params) {
|
||||
// Invalid items are ignored
|
||||
if (typeof param !== 'object') continue;
|
||||
if (!('name' in param)) continue;
|
||||
resultParams.append(param.name, param.value ?? '');
|
||||
}
|
||||
return resultParams.toString();
|
||||
};
|
||||
|
||||
|
||||
const createFormData = (data, collectionPath) => {
|
||||
// make axios work in node using form data
|
||||
// reference: https://github.com/axios/axios/issues/1006#issuecomment-320165427
|
||||
@@ -56,6 +38,5 @@ const createFormData = (data, collectionPath) => {
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
buildFormUrlEncodedPayload,
|
||||
createFormData
|
||||
}
|
||||
Reference in New Issue
Block a user