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

Function redactUrl

packages/http-recorder/src/redaction.ts:68–82  ·  view source on GitHub ↗
(
  raw: string,
  query: ReadonlyArray<string> = DEFAULT_REDACT_QUERY,
  urlRedactor?: UrlRedactor,
)

Source from the content-addressed store, hash-verified

66export type UrlRedactor = (url: string) => string
67
68export const redactUrl = (
69 raw: string,
70 query: ReadonlyArray<string> = DEFAULT_REDACT_QUERY,
71 urlRedactor?: UrlRedactor,
72) => {
73 if (!URL.canParse(raw)) return urlRedactor?.(raw) ?? raw
74 const url = new URL(raw)
75 if (url.username) url.username = REDACTED
76 if (url.password) url.password = REDACTED
77 const redacted = redactionSet(query, DEFAULT_REDACT_QUERY)
78 for (const key of url.searchParams.keys()) {
79 if (redacted.has(key.toLowerCase())) url.searchParams.set(key, REDACTED)
80 }
81 return urlRedactor?.(url.toString()) ?? url.toString()
82}
83
84export const redactHeaders = (
85 headers: Record<string, string>,

Callers 2

urlFunction · 0.70
redactedErrorRequestFunction · 0.70

Calls 2

redactionSetFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected