MCPcopy
hub / github.com/affaan-m/ECC / getTomlSection

Function getTomlSection

tests/codex-config.test.js:32–42  ·  view source on GitHub ↗
(text, sectionName)

Source from the content-addressed store, hash-verified

30}
31
32function getTomlSection(text, sectionName) {
33 const escapedSection = escapeRegExp(sectionName);
34 const headerPattern = new RegExp(`^\\s*\\[${escapedSection}\\]\\s*$`, 'm');
35 const headerMatch = headerPattern.exec(text);
36
37 assert.ok(headerMatch, `Expected TOML section to exist: [${sectionName}]`);
38
39 const afterHeader = text.slice(headerMatch.index + headerMatch[0].length);
40 const nextHeaderIndex = afterHeader.search(/^\s*\[/m);
41 return nextHeaderIndex === -1 ? afterHeader : afterHeader.slice(0, nextHeaderIndex);
42}
43
44let passed = 0;
45let failed = 0;

Callers 1

Calls 3

okMethod · 0.80
searchMethod · 0.80
escapeRegExpFunction · 0.70

Tested by

no test coverage detected