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:
Andy Clement
2017-06-02 15:40:16 -07:00
parent 4244df740b
commit 77576ed6fe
2 changed files with 26 additions and 1 deletions

View File

@@ -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(':');