Delay check if pattern ends with slash

This is a minor fix with no actual impact.

Issue: SPR-10504
This commit is contained in:
Rossen Stoyanchev
2013-05-10 12:47:44 -04:00
parent e39fe1822d
commit 0634555424

View File

@@ -168,6 +168,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
* <li>If neither instance has patterns, use an empty String (i.e. "").
* </ul>
*/
@Override
public PatternsRequestCondition combine(PatternsRequestCondition other) {
Set<String> result = new LinkedHashSet<String>();
if (!this.patterns.isEmpty() && !other.patterns.isEmpty()) {
@@ -209,6 +210,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
* or a new condition with sorted matching patterns;
* or {@code null} if no patterns match.
*/
@Override
public PatternsRequestCondition getMatchingCondition(HttpServletRequest request) {
if (this.patterns.isEmpty()) {
return this;
@@ -256,9 +258,8 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
if (this.pathMatcher.match(pattern, lookupPath)) {
return pattern;
}
boolean endsWithSlash = pattern.endsWith("/");
if (this.useTrailingSlashMatch) {
if (!endsWithSlash && this.pathMatcher.match(pattern + "/", lookupPath)) {
if (!pattern.endsWith("/") && this.pathMatcher.match(pattern + "/", lookupPath)) {
return pattern +"/";
}
}
@@ -277,6 +278,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
* contain only patterns that match the request and are sorted with
* the best matches on top.
*/
@Override
public int compareTo(PatternsRequestCondition other, HttpServletRequest request) {
String lookupPath = this.pathHelper.getLookupPathForRequest(request);
Comparator<String> patternComparator = this.pathMatcher.getPatternComparator(lookupPath);