Skip to content

Commit 0634555

Browse files
committed
Delay check if pattern ends with slash
This is a minor fix with no actual impact. Issue: SPR-10504
1 parent e39fe18 commit 0634555

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ protected String getToStringInfix() {
168168
* <li>If neither instance has patterns, use an empty String (i.e. "").
169169
* </ul>
170170
*/
171+
@Override
171172
public PatternsRequestCondition combine(PatternsRequestCondition other) {
172173
Set<String> result = new LinkedHashSet<String>();
173174
if (!this.patterns.isEmpty() && !other.patterns.isEmpty()) {
@@ -209,6 +210,7 @@ else if (!other.patterns.isEmpty()) {
209210
* or a new condition with sorted matching patterns;
210211
* or {@code null} if no patterns match.
211212
*/
213+
@Override
212214
public PatternsRequestCondition getMatchingCondition(HttpServletRequest request) {
213215
if (this.patterns.isEmpty()) {
214216
return this;
@@ -256,9 +258,8 @@ private String getMatchingPattern(String pattern, String lookupPath) {
256258
if (this.pathMatcher.match(pattern, lookupPath)) {
257259
return pattern;
258260
}
259-
boolean endsWithSlash = pattern.endsWith("/");
260261
if (this.useTrailingSlashMatch) {
261-
if (!endsWithSlash && this.pathMatcher.match(pattern + "/", lookupPath)) {
262+
if (!pattern.endsWith("/") && this.pathMatcher.match(pattern + "/", lookupPath)) {
262263
return pattern +"/";
263264
}
264265
}
@@ -277,6 +278,7 @@ private String getMatchingPattern(String pattern, String lookupPath) {
277278
* contain only patterns that match the request and are sorted with
278279
* the best matches on top.
279280
*/
281+
@Override
280282
public int compareTo(PatternsRequestCondition other, HttpServletRequest request) {
281283
String lookupPath = this.pathHelper.getLookupPathForRequest(request);
282284
Comparator<String> patternComparator = this.pathMatcher.getPatternComparator(lookupPath);

0 commit comments

Comments
 (0)