MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / parseString

Function parseString

tools/sendNotify.js:1407–1431  ·  view source on GitHub ↗
(input, valueFormatFn)

Source from the content-addressed store, hash-verified

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

Callers 1

parseBodyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected