Skip to main content
Redact secrets from a URL before it is recorded as a span attribute, following the OpenTelemetry URL semantic conventions: sensitive query-parameter values and user:pass@ credentials are replaced with the literal REDACTED, with the parameter key preserved (sig=REDACTED). Non-sensitive parameters and the path are left intact. Built to pair with the redactUrl fetch option, e.g. createInstrumentedFetch(undefined, { redactUrl: (u) => sanitizeUrl(u, { params: ["token"] }) }). Unparseable input — and input with nothing to redact — is returned unchanged (no query-string re-encoding when no secret matched).

Parameters

string
required

Returns

string