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

Function readProxyMatcher

src/resolution/frameworks/next-proxy.ts:113–141  ·  view source on GitHub ↗
(safe: string)

Source from the content-addressed store, hash-verified

111 * template with holes, so such a matcher reads as `[]`, never as `'all'`.
112 */
113export function readProxyMatcher(safe: string): ProxyMatcherEntry[] | 'all' {
114 const decl = /\bexport\s+const\s+config\b[^=;]*=\s*/.exec(safe);
115 if (!decl) return 'all';
116 const open = decl.index + decl[0].length;
117 const close = safe[open] === '{' ? matchBracket(safe, open) : -1;
118 if (close < 0) return [];
119 const field = readFields(safe, open, close).get('matcher');
120 // A shorthand or a quoted key is a matcher this can't see into.
121 if (!field) return /\bmatcher\b/.test(safe.slice(open, close)) ? [] : 'all';
122 const at = valueAfterKey(safe, field.at);
123 if (safe[at] !== '[') {
124 const one = stringEntry(safe, at);
125 return one ? [one] : [];
126 }
127 const end = matchBracket(safe, at);
128 const entries: ProxyMatcherEntry[] = [];
129 for (let i = at + 1; i > 0 && i < end; ) {
130 const ch = safe[i]!;
131 if (/[\s,]/.test(ch)) {
132 i++;
133 continue;
134 }
135 const entry = ch === '{' ? sourceEntry(safe, i) : stringEntry(safe, i);
136 if (!entry) return [];
137 entries.push(entry);
138 i = afterElement(safe, i, end);
139 }
140 return entries;
141}
142
143function sourceEntry(s: string, open: number): ProxyMatcherEntry | null {
144 const source = readFields(s, open, matchBracket(s, open)).get('source');

Callers 3

nextProxyEdgesFunction · 0.90
readFunction · 0.90

Calls 9

matchBracketFunction · 0.90
readFieldsFunction · 0.90
valueAfterKeyFunction · 0.85
stringEntryFunction · 0.85
sourceEntryFunction · 0.85
afterElementFunction · 0.85
pushMethod · 0.80
execMethod · 0.65
getMethod · 0.65

Tested by 1

readFunction · 0.72