Rollback AntPathMatcher behavior for ".*" comparisons
Prior to this commit, AntPathMatcher had been refactored for SPR-6741.
During that process, a key feature has been removed:
When comparing two patterns, pattern elements (*, {}, etc) are counted
to score those patterns. When a pattern ends with ".*", the ending
wildcard should not be counted against pattern elements for this
pattern.
This commit reintroduces that behavior.
Issue: SPR-6741
This commit is contained in:
@@ -696,11 +696,15 @@ public class AntPathMatcher implements PathMatcher {
|
||||
this.doubleWildcards++;
|
||||
pos += 2;
|
||||
}
|
||||
else {
|
||||
else if(!this.pattern.substring(pos - 1).equals(".*")) {
|
||||
this.singleWildcards++;
|
||||
pos++;
|
||||
}
|
||||
} else {
|
||||
else {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,6 +451,7 @@ public class AntPathMatcherTests {
|
||||
assertEquals(1, comparator.compare("/hotels/*/**", "/hotels/*"));
|
||||
|
||||
assertEquals(-1, comparator.compare("/hotels/new", "/hotels/new.*"));
|
||||
assertEquals(2, comparator.compare("/hotels/{hotel}", "/hotels/{hotel}.*"));
|
||||
|
||||
//SPR-6741
|
||||
assertEquals(-1, comparator.compare("/hotels/{hotel}/bookings/{booking}/cutomers/{customer}", "/hotels/**"));
|
||||
|
||||
Reference in New Issue
Block a user