redactUrl method

String redactUrl(
  1. String url, {
  2. required bool useRedaction,
})

Redacts query parameter values and userInfo credentials in a URL.

Returns the original URL string if redaction is disabled or the URL has nothing to redact. Delegates to RedactionService.redactUrl.

Implementation

String redactUrl(String url, {required bool useRedaction}) {
  final prepared = LogExportOutput.truncateUtf8(
    url,
    maxBytes: resourceLimits.maxCapturedValueBytes,
  );
  if (!useRedaction) return prepared;
  try {
    return LogExportOutput.truncateUtf8(
      redactor.redactUrl(prepared),
      maxBytes: resourceLimits.maxCapturedValueBytes,
    );
  } on Object {
    _logRedactionFailure();
    return ph.redactionFailedPlaceholder;
  }
}