fixed parsind of extended community search filters

This commit is contained in:
Annika Hannig 2022-11-16 16:30:44 +01:00
parent 4db3f39baa
commit 4db8affe13

View File

@ -1,6 +1,7 @@
package api
import (
"fmt"
"strconv"
"strings"
)
@ -62,10 +63,15 @@ func parseExtCommunityValue(value string) (*SearchFilter, error) {
components := strings.Split(value, ":")
community := make(ExtCommunity, len(components))
for i, c := range components {
community[i] = c
if len(community) != 3 {
return nil, fmt.Errorf("malformed ext. community: %s", value)
}
// Communities are not stringly typed, but a mix of string and int
community[0] = components[0]
community[1], _ = strconv.Atoi(components[1])
community[2], _ = strconv.Atoi(components[2])
return &SearchFilter{
Name: community.String(),
Value: community,