MCPcopy Create free account
hub / github.com/simstudioai/sim / applyReplace

Function applyReplace

apps/sim/lib/guardrails/validate_pii.test.ts:15–21  ·  view source on GitHub ↗

Mimic the Presidio anonymizer's default `replace`: each span → ` `.

(text: string, results: Span[])

Source from the content-addressed store, hash-verified

13
14/** Mimic the Presidio anonymizer's default `replace`: each span → `<ENTITY_TYPE>`. */
15function applyReplace(text: string, results: Span[]): string {
16 let out = text
17 for (const s of [...results].sort((a, b) => b.start - a.start)) {
18 out = `${out.slice(0, s.start)}<${s.entity_type}>${out.slice(s.end)}`
19 }
20 return out
21}
22
23/** Analyzer mock: flags `a@b.com` as EMAIL_ADDRESS when that entity is in scope. */
24function emailSpans(text: string, entities: string[] | undefined): Span[] {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected