SPR-6280 - PathVariable resolution does not work properly

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2499 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Arjen Poutsma
2009-11-24 13:53:37 +00:00
parent 26d4c0df55
commit c2b7b406c4
6 changed files with 102 additions and 8 deletions
@@ -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();
}
}