MCPcopy
hub / github.com/garrytan/gstack / hasNear

Function hasNear

lib/redact-engine.ts:227–239  ·  view source on GitHub ↗
(
  normalized: string,
  matchStart: number,
  matchEnd: number,
  nearRegex: RegExp,
  window: number,
)

Source from the content-addressed store, hash-verified

225// ── Proximity check ───────────────────────────────────────────────────────────
226
227function hasNear(
228 normalized: string,
229 matchStart: number,
230 matchEnd: number,
231 nearRegex: RegExp,
232 window: number,
233): boolean {
234 const from = Math.max(0, matchStart - window);
235 const to = Math.min(normalized.length, matchEnd + window);
236 const slice = normalized.slice(from, to);
237 const re = new RegExp(nearRegex.source, nearRegex.flags.replace(/g/g, ""));
238 return re.test(slice);
239}
240
241// ── Email allowlist ───────────────────────────────────────────────────────────
242

Callers 1

scanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected