SPR-6280 - PathVariable resolution does not work properly
This commit is contained in:
@@ -412,7 +412,7 @@ public class AntPathMatcher implements PathMatcher {
|
||||
else if (bracketCount2 < bracketCount1) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return pattern2.length() - pattern1.length();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class AntPathStringMatcher {
|
||||
|
||||
private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{([^/]+?)\\}");
|
||||
|
||||
private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
|
||||
private static final String DEFAULT_VARIABLE_PATTERN = "([^\\.]*)";
|
||||
|
||||
private final Pattern pattern;
|
||||
|
||||
|
||||
@@ -395,6 +395,11 @@ public class AntPathMatcherTests {
|
||||
|
||||
assertEquals(-1, comparator.compare("/hotels/*", "/hotels/*/**"));
|
||||
assertEquals(1, comparator.compare("/hotels/*/**", "/hotels/*"));
|
||||
|
||||
assertEquals(-1, comparator.compare("/hotels/new", "/hotels/new.*"));
|
||||
|
||||
// longer is better
|
||||
assertEquals(1, comparator.compare("/hotels", "/hotels2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -467,6 +472,14 @@ public class AntPathMatcherTests {
|
||||
assertEquals("/hotels/{hotel}", paths.get(1));
|
||||
assertEquals("/hotels/*", paths.get(2));
|
||||
paths.clear();
|
||||
|
||||
paths.add("/hotels/ne*");
|
||||
paths.add("/hotels/n*");
|
||||
Collections.shuffle(paths);
|
||||
Collections.sort(paths, comparator);
|
||||
assertEquals("/hotels/ne*", paths.get(0));
|
||||
assertEquals("/hotels/n*", paths.get(1));
|
||||
paths.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user