Fix PathPattern comparator result for wildcard suffix usage
Without this change the comparator thinks "/{foo}"
is more specific than "/{foo}.*". The minimal fix here
to address it is to copy what the AntPathMatcher
comparator does which is to consider '.*' as *not*
a usage of a wildcard. See PatternInfo#initCounters()
for the AntPathMatcher handling of this.
This change ensures the PathPattern comparator now produces
the expected result but suffix usage in general needs more
thought at some point.
Issue: SPR-15597
This commit is contained in:
@@ -72,7 +72,12 @@ class RegexPathElement extends PathElement {
|
||||
}
|
||||
else if ("*".equals(match)) {
|
||||
patternBuilder.append(".*");
|
||||
this.wildcardCount++;
|
||||
int pos = matcher.start();
|
||||
if (pos < 1 || text.charAt(pos-1) != '.') {
|
||||
// To be compatible with the AntPathMatcher comparator,
|
||||
// '.*' is not considered a wildcard usage
|
||||
this.wildcardCount++;
|
||||
}
|
||||
}
|
||||
else if (match.startsWith("{") && match.endsWith("}")) {
|
||||
int colonIdx = match.indexOf(':');
|
||||
|
||||
Reference in New Issue
Block a user