stripInternalRoutingKeys function

dynamic stripInternalRoutingKeys(
  1. dynamic message
)

Strip transport-internal routing metadata from an outbound message.

Returns message unchanged when it carries none, so the common path costs nothing.

Implementation

dynamic stripInternalRoutingKeys(dynamic message) {
  if (message is! Map) return message;
  if (!_internalRoutingKeys.any(message.containsKey)) return message;
  final clean = Map<String, dynamic>.from(message);
  for (final key in _internalRoutingKeys) {
    clean.remove(key);
  }
  return clean;
}