Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:fix api match when using IN or NOT_IN. #569

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading