redactText static method

String redactText(
  1. String input
)

Redacts sensitive values from text output.

Implementation

static String redactText(String input) {
  if (input.isEmpty) return input;
  var sanitized = input;

  for (final pattern in _secretValuePatterns) {
    sanitized = sanitized.replaceAllMapped(
      pattern,
      (match) {
        final prefix = match.groupCount >= 1 ? match.group(1) : '';
        return '$prefix[REDACTED]';
      },
    );
  }

  return sanitized;
}