Skip to content

Commit

Permalink
fix:fix api match when using IN or NOT_IN. (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyeBeFreeman authored Nov 25, 2024
1 parent 5b79f39 commit f46295f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static boolean matchStringValue(MatchStringType matchType, String actualV
String[] tokens = matchValue.split(",");
for (String token : tokens) {
if (useTrieNode && trieNodeFunction != null) {
if (TrieUtil.checkSimpleApi(trieNodeFunction.apply(matchValue), actualValue)) {
if (TrieUtil.checkSimpleApi(trieNodeFunction.apply(token), actualValue)) {
return true;
}
} else {
Expand All @@ -127,7 +127,7 @@ public static boolean matchStringValue(MatchStringType matchType, String actualV
String[] tokens = matchValue.split(",");
for (String token : tokens) {
if (useTrieNode && trieNodeFunction != null) {
if (TrieUtil.checkSimpleApi(trieNodeFunction.apply(matchValue), actualValue)) {
if (TrieUtil.checkSimpleApi(trieNodeFunction.apply(token), actualValue)) {
return false;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ public void testMatchMetadata() {
assertThat(matchMetadata(ruleMeta3, destMeta3)).isTrue();
}

@Test
public void testInMatch() {
assertThat(matchStringValue(ModelProto.MatchString.MatchStringType.IN, "123", "123,456")).isTrue();
assertThat(matchStringValue(ModelProto.MatchString.MatchStringType.IN, "123", "456,123")).isTrue();
assertThat(matchStringValue(ModelProto.MatchString.MatchStringType.IN, "231", "123,456")).isFalse();
assertThat(matchStringValue(ModelProto.MatchString.MatchStringType.NOT_IN, "123", "123,456")).isFalse();
assertThat(matchStringValue(ModelProto.MatchString.MatchStringType.NOT_IN, "123", "456,123")).isFalse();
assertThat(matchStringValue(ModelProto.MatchString.MatchStringType.NOT_IN, "231", "123,456")).isTrue();
}

@Test
public void testRangeMatch() {
assertThat(matchStringValue(ModelProto.MatchString.MatchStringType.RANGE, "123", "123~456")).isTrue();
Expand Down

0 comments on commit f46295f

Please sign in to comment.