RSRParser to support inner brackets

This commit is contained in:
DanB
2019-01-28 19:20:46 +01:00
parent 05ec79ebf0
commit 6c90848774
2 changed files with 3 additions and 7 deletions

View File

@@ -119,7 +119,7 @@ func NewRSRParser(parserRules string, allFiltersMatch bool) (rsrParser *RSRParse
}
rsrParser = &RSRParser{Rules: parserRules, AllFiltersMatch: allFiltersMatch}
if strings.HasSuffix(parserRules, utils.FILTER_VAL_END) { // Has filter, populate the var
fltrStart := strings.LastIndex(parserRules, utils.FILTER_VAL_START)
fltrStart := strings.Index(parserRules, utils.FILTER_VAL_START)
if fltrStart < 1 {
return nil, fmt.Errorf("invalid RSRFilter start rule in string: <%s>", parserRules)
}

View File

@@ -153,19 +153,15 @@ func TestRSRParsersParseEvent3(t *testing.T) {
}
}
/*
// Need to review RSRParser to accept ()
func TestRSRParsersParseWrong(t *testing.T) {
// TestRSRParsersParseInnerBraces makes sure the inner braces are allowed in a filter rule
func TestRSRParsersParseInnerBracket(t *testing.T) {
rule := "~*req.Service-Information.IN-Information.CalledPartyAddress(~^(00)*(33|0)890240004$)"
prsr, err := NewRSRParser(rule, true)
if err != nil {
t.Error(err)
}
expAttrName := "*req.Service-Information.IN-Information.CalledPartyAddress"
// we expected to get *req.Service-Information.IN-Information.CalledPartyAddress as attrName
// and the rest go in filters
if prsr.AttrName() != expAttrName {
t.Errorf("expecting: %s, received: %s", expAttrName, prsr.AttrName())
}
}
*/