mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 07:08:45 +05:00
Diameter - completing field templates for individual messages
This commit is contained in:
@@ -166,6 +166,9 @@ func (rsrFltr *RSRFilter) Pass(val string) bool {
|
||||
if rsrFltr.filterRule[:1] == REGEXP_PREFIX {
|
||||
return rsrFltr.fltrRgxp.MatchString(val) != rsrFltr.negative
|
||||
}
|
||||
if rsrFltr.filterRule == "^$" { // Special case to test empty value
|
||||
return len(val) == 0 != rsrFltr.negative
|
||||
}
|
||||
if rsrFltr.filterRule[:1] == MatchStartPrefix {
|
||||
return strings.HasPrefix(val, rsrFltr.filterRule[1:]) != rsrFltr.negative
|
||||
}
|
||||
|
||||
@@ -341,4 +341,14 @@ func TestRSRFilterPass(t *testing.T) {
|
||||
if fltr.Pass("CGRateS") {
|
||||
t.Error("Passing!")
|
||||
}
|
||||
fltr, err = NewRSRFilter("^$") // Empty value
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if fltr.Pass("CGRateS") {
|
||||
t.Error("Passing!")
|
||||
}
|
||||
if !fltr.Pass("") {
|
||||
t.Error("Not passing!")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user