Choose exact transition match if available

This commit is contained in:
Patrick Cockwell
2019-09-30 16:41:44 -07:00
committed by Cory Bennett
parent 2062dffc60
commit 62ccffaf05
+8 -1
View File
@@ -9,10 +9,17 @@ import (
// or nil // or nil
func (t Transitions) Find(name string) *Transition { func (t Transitions) Find(name string) *Transition {
name = strings.ToLower(name) name = strings.ToLower(name)
matches := []Transitions{}
for _, trans := range t { for _, trans := range t {
if strings.Contains(strings.ToLower(trans.Name), name) { if strings.Compare(strings.ToLower(trans.Name), name) == 0 {
return trans return trans
} }
if strings.Contains(strings.ToLower(trans.Name), name) {
matches = append(matches, trans)
}
}
if len(matches) > 0 {
return matches[0]
} }
return nil return nil
} }