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

Function parseString

sendNofity.js:1411–1435  ·  view source on GitHub ↗
(input, valueFormatFn)

Source from the content-addressed store, hash-verified

1409}
1410
1411function parseString(input, valueFormatFn) {
1412 const regex = /(\w+):\s*((?:(?!\n\w+:).)*)/g;
1413 const matches = {};
1414
1415 let match;
1416 while ((match = regex.exec(input)) !== null) {
1417 const [, key, value] = match;
1418 const _key = key.trim();
1419 if (!_key || matches[_key]) {
1420 continue;
1421 }
1422
1423 let _value = value.trim();
1424
1425 try {
1426 _value = valueFormatFn ? valueFormatFn(_value) : _value;
1427 const jsonValue = JSON.parse(_value);
1428 matches[_key] = jsonValue;
1429 } catch (error) {
1430 matches[_key] = _value;
1431 }
1432 }
1433
1434 return matches;
1435}
1436
1437function parseHeaders(headers) {
1438 if (!headers) return {};

Callers 1

parseBodyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected