Fix exception in AntPathMatcher for leading *

Issue: SPR-13139
This commit is contained in:
Martin Lippert 2015-06-17 17:33:34 +02:00 committed by Rossen Stoyanchev
parent be4329545a
commit 63f01c851f
2 changed files with 5 additions and 1 deletions

View File

@ -747,7 +747,7 @@ public class AntPathMatcher implements PathMatcher {
this.doubleWildcards++;
pos += 2;
}
else if (!this.pattern.substring(pos - 1).equals(".*")) {
else if (pos > 0 && !this.pattern.substring(pos - 1).equals(".*")) {
this.singleWildcards++;
pos++;
}

View File

@ -479,6 +479,10 @@ public class AntPathMatcherTests {
// longer is better
assertEquals(1, comparator.compare("/hotels", "/hotels2"));
//SPR-13139
assertEquals(-1, comparator.compare("*", "*/**"));
assertEquals(1, comparator.compare("*/**", "*"));
}
@Test