The text with every occurrence of the trimmed secret replaced by [redacted], or the text unchanged
when the secret is shorter than 8 characters: an empty key, or a placeholder such as x, whose
replacement would mangle ordinary words. Decision drivers run it over an error body before any of it
reaches an error message, so no truncation can leave part of an API key behind, and again over the
message, which can hold a key the body carried JSON-escaped.
Parameters
text: string
The text to redact, such as a response body.
secret: string
The secret to remove, such as the credential's API key.
The text with every occurrence of the trimmed secret replaced by
[redacted], or the text unchanged when the secret is shorter than 8 characters: an empty key, or a placeholder such asx, whose replacement would mangle ordinary words. Decision drivers run it over an error body before any of it reaches an error message, so no truncation can leave part of an API key behind, and again over the message, which can hold a key the body carried JSON-escaped.