MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / parseBody

Function parseBody

sendNofity.js:1461–1481  ·  view source on GitHub ↗
(body, contentType, valueFormatFn)

Source from the content-addressed store, hash-verified

1459}
1460
1461function parseBody(body, contentType, valueFormatFn) {
1462 if (contentType === 'text/plain' || !body) {
1463 return valueFormatFn && body ? valueFormatFn(body) : body;
1464 }
1465
1466 const parsed = parseString(body, valueFormatFn);
1467
1468 switch (contentType) {
1469 case 'multipart/form-data':
1470 return Object.keys(parsed).reduce((p, c) => {
1471 p.append(c, parsed[c]);
1472 return p;
1473 }, new FormData());
1474 case 'application/x-www-form-urlencoded':
1475 return Object.keys(parsed).reduce((p, c) => {
1476 return p ? `${p}&${c}=${parsed[c]}` : `${c}=${parsed[c]}`;
1477 });
1478 }
1479
1480 return parsed;
1481}
1482
1483function formatBodyFun(contentType, body) {
1484 if (!body) return {};

Callers 1

webhookNotifyFunction · 0.70

Calls 1

parseStringFunction · 0.70

Tested by

no test coverage detected