Compare suffix patterns by length
Closes gh-23125
This commit is contained in:
@@ -776,7 +776,10 @@ public class AntPathMatcher implements PathMatcher {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info1.isPrefixPattern() && info2.getDoubleWildcards() == 0) {
|
if (info1.isPrefixPattern() && info2.isPrefixPattern()) {
|
||||||
|
return info2.getLength() - info1.getLength();
|
||||||
|
}
|
||||||
|
else if (info1.isPrefixPattern() && info2.getDoubleWildcards() == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (info2.isPrefixPattern() && info1.getDoubleWildcards() == 0) {
|
else if (info2.isPrefixPattern() && info1.getDoubleWildcards() == 0) {
|
||||||
|
|||||||
@@ -481,8 +481,9 @@ public class AntPathMatcherTests {
|
|||||||
assertThat(comparator.compare("/hotels/**", "/hotels/{hotel}/bookings/{booking}/cutomers/{customer}")).isEqualTo(1);
|
assertThat(comparator.compare("/hotels/**", "/hotels/{hotel}/bookings/{booking}/cutomers/{customer}")).isEqualTo(1);
|
||||||
assertThat(comparator.compare("/hotels/foo/bar/**", "/hotels/{hotel}")).isEqualTo(1);
|
assertThat(comparator.compare("/hotels/foo/bar/**", "/hotels/{hotel}")).isEqualTo(1);
|
||||||
assertThat(comparator.compare("/hotels/{hotel}", "/hotels/foo/bar/**")).isEqualTo(-1);
|
assertThat(comparator.compare("/hotels/{hotel}", "/hotels/foo/bar/**")).isEqualTo(-1);
|
||||||
assertThat(comparator.compare("/hotels/**/bookings/**", "/hotels/**")).isEqualTo(2);
|
|
||||||
assertThat(comparator.compare("/hotels/**", "/hotels/**/bookings/**")).isEqualTo(-2);
|
// gh-23125
|
||||||
|
assertThat(comparator.compare("/hotels/*/bookings/**", "/hotels/**")).isEqualTo(-11);
|
||||||
|
|
||||||
// SPR-8683
|
// SPR-8683
|
||||||
assertThat(comparator.compare("/**", "/hotels/{hotel}")).isEqualTo(1);
|
assertThat(comparator.compare("/**", "/hotels/{hotel}")).isEqualTo(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user