Merge pull request #60 from hobbyistlabs-coder/bolt/optimize-routing-route-comparisons-16744250566710388366
⚡ Bolt: Optimize case-insensitive routing comparisons
This commit is contained in:
commit
4110397d97
1 changed files with 5 additions and 5 deletions
|
|
@ -121,8 +121,8 @@ func (r *RouteResolver) ResolveRoute(input RouteInput) ResolvedRoute {
|
||||||
func (r *RouteResolver) filterBindings(channel, accountID string) []config.AgentBinding {
|
func (r *RouteResolver) filterBindings(channel, accountID string) []config.AgentBinding {
|
||||||
var filtered []config.AgentBinding
|
var filtered []config.AgentBinding
|
||||||
for _, b := range r.cfg.Bindings {
|
for _, b := range r.cfg.Bindings {
|
||||||
matchChannel := strings.ToLower(strings.TrimSpace(b.Match.Channel))
|
matchChannel := strings.TrimSpace(b.Match.Channel)
|
||||||
if matchChannel == "" || matchChannel != channel {
|
if matchChannel == "" || !strings.EqualFold(matchChannel, channel) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !matchesAccountID(b.Match.AccountID, accountID) {
|
if !matchesAccountID(b.Match.AccountID, accountID) {
|
||||||
|
|
@ -141,7 +141,7 @@ func matchesAccountID(matchAccountID, actual string) bool {
|
||||||
if trimmed == "*" {
|
if trimmed == "*" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return strings.ToLower(trimmed) == strings.ToLower(actual)
|
return strings.EqualFold(trimmed, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RouteResolver) findPeerMatch(bindings []config.AgentBinding, peer *RoutePeer) *config.AgentBinding {
|
func (r *RouteResolver) findPeerMatch(bindings []config.AgentBinding, peer *RoutePeer) *config.AgentBinding {
|
||||||
|
|
@ -150,12 +150,12 @@ func (r *RouteResolver) findPeerMatch(bindings []config.AgentBinding, peer *Rout
|
||||||
if b.Match.Peer == nil {
|
if b.Match.Peer == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
peerKind := strings.ToLower(strings.TrimSpace(b.Match.Peer.Kind))
|
peerKind := strings.TrimSpace(b.Match.Peer.Kind)
|
||||||
peerID := strings.TrimSpace(b.Match.Peer.ID)
|
peerID := strings.TrimSpace(b.Match.Peer.ID)
|
||||||
if peerKind == "" || peerID == "" {
|
if peerKind == "" || peerID == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if peerKind == strings.ToLower(peer.Kind) && peerID == peer.ID {
|
if strings.EqualFold(peerKind, peer.Kind) && peerID == peer.ID {
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue