mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-03 01:18:32 +00:00
fix: harden type checks for buildFormUrlEncodedPayload (#5811)
This commit is contained in:
committed by
GitHub
parent
4c3a9928bc
commit
2becf49542
@@ -8,9 +8,14 @@ const path = require('path');
|
||||
* @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) {
|
||||
resultParams.append(param.name, param.value);
|
||||
// Invalid items are ignored
|
||||
if (typeof param !== 'object') continue;
|
||||
if (!('name' in param)) continue;
|
||||
resultParams.append(param.name, param.value ?? '');
|
||||
}
|
||||
return resultParams.toString();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user