19 lines
393 B
TypeScript
19 lines
393 B
TypeScript
type Params = {
|
|
text?: string | null;
|
|
secrets: string[];
|
|
};
|
|
|
|
export default function redactSecrets({ text, secrets }: Params) {
|
|
let output = text || "";
|
|
|
|
for (let i = 0; i < secrets.length; i++) {
|
|
const secret = secrets[i];
|
|
|
|
if (secret && secret.length >= 4) {
|
|
output = output.split(secret).join(`[redacted]`);
|
|
}
|
|
}
|
|
|
|
return output;
|
|
}
|