MCPcopy
hub / github.com/infinitered/reactotron / compileCombinedValueRegex

Function compileCombinedValueRegex

lib/reactotron-mcp/src/redaction.ts:209–225  ·  view source on GitHub ↗

* Validate each pattern individually so one bad regex doesn't kill the rest, * then fold the survivors into a single alternation for one-pass matching.

(patterns: string[])

Source from the content-addressed store, hash-verified

207 * then fold the survivors into a single alternation for one-pass matching.
208 */
209function compileCombinedValueRegex(patterns: string[]): RegExp | null {
210 const valid: string[] = []
211 for (const pattern of patterns) {
212 try {
213 new RegExp(pattern)
214 valid.push(pattern)
215 } catch {
216 // Invalid regex — skip
217 }
218 }
219 if (valid.length === 0) return null
220 try {
221 return new RegExp(valid.map((p) => `(?:${p})`).join("|"), "g")
222 } catch {
223 return null
224 }
225}
226
227function parseRules(rules: McpRedactionRules): ParsedRules {
228 const statePathPatterns = rules.statePathPatterns ?? []

Callers 1

parseRulesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected