Fixed case sensitive matcher

This commit is contained in:
Volodymyr Babak 2025-06-11 12:16:56 +03:00
parent e21850f571
commit aaead18263

View File

@ -54,7 +54,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -338,7 +337,7 @@ public class RepositoryUtils {
return toSqlLikePattern(filter, ".*", "$"); return toSqlLikePattern(filter, ".*", "$");
} }
private static Pattern toSqlLikePattern(String value, String prefix, String suffix ) { private static Pattern toSqlLikePattern(String value, String prefix, String suffix) {
if (value.contains("%") || value.contains("_")) { if (value.contains("%") || value.contains("_")) {
String regexValue = value String regexValue = value
.replace("_", ".") .replace("_", ".")
@ -351,9 +350,9 @@ public class RepositoryUtils {
} else { } else {
regex = (regexValue.startsWith(".*") ? "" : ".*") + regexValue + (regexValue.endsWith(".*") ? "" : ".*"); regex = (regexValue.startsWith(".*") ? "" : ".*") + regexValue + (regexValue.endsWith(".*") ? "" : ".*");
} }
return Pattern.compile(regex, Pattern.CASE_INSENSITIVE); return Pattern.compile(regex);
} else { } else {
return Pattern.compile(prefix + Pattern.quote(value) + suffix, Pattern.CASE_INSENSITIVE); return Pattern.compile(prefix + Pattern.quote(value) + suffix);
} }
} }