Assign lowest priority to /** pattern

Update AntPathMatcher Comparator to treat `/**` in the same way as
`null` paths.

Prior to this commit the pattern `/**` would be picked in preference
to patterns with 3 or more PathVariable (e.g. `/matches/{matchId}/
periods/{periodId}/teams/{teamId}/results`).

Issue: SPR-10550
This commit is contained in:
Antonio Marrero
2013-06-24 16:17:01 +01:00
committed by Phillip Webb
parent c1dafed886
commit 57f7b14b49
2 changed files with 14 additions and 3 deletions

View File

@@ -437,6 +437,11 @@ public class AntPathMatcherTests {
assertEquals(-1, comparator.compare("/hotels/{hotel}/booking", "/hotels/{hotel}/bookings/{booking}"));
assertEquals(1, comparator.compare("/hotels/{hotel}/bookings/{booking}", "/hotels/{hotel}/booking"));
//SPR-10550
assertEquals(-1, comparator.compare("/hotels/{hotel}/bookings/{booking}/cutomers/{customer}", "/**"));
assertEquals(1, comparator.compare("/**","/hotels/{hotel}/bookings/{booking}/cutomers/{customer}"));
assertEquals(0, comparator.compare("/**","/**"));
assertEquals(-1, comparator.compare("/hotels/{hotel}", "/hotels/*"));
assertEquals(1, comparator.compare("/hotels/*", "/hotels/{hotel}"));