MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / readGroup

Function readGroup

src/resolution/frameworks/next-proxy.ts:242–254  ·  view source on GitHub ↗

* The inside of a matcher's group: `.*`, `.+`, `a|b` of literals, or * `(?!a|b|….*\.png$).*`, the form almost every real matcher takes.

(body: string)

Source from the content-addressed store, hash-verified

240 * `(?!a|b|….*\.png$).*`, the form almost every real matcher takes.
241 */
242function readGroup(body: string): string | null {
243 if (body === '.*' || body === '.+') return body;
244 if (body.startsWith('(?!')) {
245 const close = closingParen(body, 0);
246 const tail = close < 0 ? '' : body.slice(close + 1);
247 if (tail !== '.*' && tail !== '.+') return null;
248 const branches = topLevelBars(body.slice(3, close)).map(readExclusion);
249 return branches.includes(null) ? null : `(?!${[...new Set(branches)].join('|')})${tail}`;
250 }
251 const options = topLevelBars(body.replace(/^\?:/, ''));
252 if (!options.every((option) => /^[\w./~-]+$/.test(option))) return null;
253 return `(?:${options.map(escapeRegex).join('|')})`;
254}
255
256/**
257 * A matcher entry as a regular expression, or null for one this doesn't read,

Callers 1

compileMatcherFunction · 0.85

Calls 4

closingParenFunction · 0.85
topLevelBarsFunction · 0.85
mapMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected