package envelope import "strings" // NormalizeSourceEndpointKey returns the stable, low-cardinality source key used // by identity lookup and statistics source tracking. func NormalizeSourceEndpointKey(endpoint string) string { endpoint = strings.TrimSpace(endpoint) if endpoint == "" { return "" } if strings.HasPrefix(strings.ToLower(endpoint), "mqtt://") { return "mqtt" } if host, _, ok := strings.Cut(endpoint, ":"); ok { return strings.TrimSpace(host) } return endpoint }