in apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/matcher/FastPathMatcher.java [84:138]
private boolean wildcardMatch(String pat, int p, String str, int s) {
char pc = safeCharAt(pat, p);
// End of pattern, check string only has zero or one '/' at end.
// ↓ ↓
// pattern: a/* a/*
// ↓ ↓
// string: a/bc/ a/bc
if (pc == 0) {
while (true) {
char sc = safeCharAt(str, s);
// No '/' found
if (sc == 0) return true;
// Check '/' is the last char of string
if (sc == '/') return s == str.length() - 1;
s++;
}
}
while (true) {
char sc = safeCharAt(str, s);
if (sc == '/') {
// Both of pattern and string '/' matched, exit wildcard mode.
// ↓
// pattern: a/*/
// ↓
// string: a/bc/
if (pc == sc) {
return normalMatch(pat, p + 1, str, s + 1);
}
// Not matched string in current path part.
// ↓ ↓
// pattern: a/* a/*d
// ↓ ↓
// string: a/bc/ a/bc/
return false;
}
// Try to enter normal mode, if not matched, increasing pointer of string and try again.
if (!normalMatch(pat, p, str, s)) {
// End of string, not matched.
if (s >= str.length()) {
return false;
}
s++;
continue;
}
// Matched in next normal mode.
return true;
}
}