MCPcopy Create free account
hub / github.com/anomalyco/opencode / redactBody

Function redactBody

packages/http-recorder/src/redactor.ts:96–102  ·  view source on GitHub ↗
(value: string, fields: ReadonlySet<string>, transform: ((body: string) => string) | undefined)

Source from the content-addressed store, hash-verified

94}
95
96const redactBody = (value: string, fields: ReadonlySet<string>, transform: ((body: string) => string) | undefined) => {
97 const redacted = Option.match(decodeJson(value), {
98 onNone: () => value,
99 onSome: (parsed) => JSON.stringify(redactJsonFields(parsed, fields)),
100 })
101 return transform?.(redacted) ?? redacted
102}
103
104export const make = (options: RedactOptions = {}): Redactor => {
105 const fields = new Set([...DEFAULT_REDACT_JSON_FIELDS, ...(options.jsonFields ?? [])].map(normalizeField))

Callers 1

makeFunction · 0.70

Calls 2

redactJsonFieldsFunction · 0.85
transformFunction · 0.85

Tested by

no test coverage detected