Merge branch '5.1.x'
This commit is contained in:
commit
71396121a7
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -169,7 +169,21 @@ public class AntPathMatcher implements PathMatcher {
|
|||
|
||||
@Override
|
||||
public boolean isPattern(String path) {
|
||||
return (path.indexOf('*') != -1 || path.indexOf('?') != -1);
|
||||
boolean uriVar = false;
|
||||
for (int i = 0; i < path.length(); i++) {
|
||||
char c = path.charAt(i);
|
||||
if (c == '*' || c == '?') {
|
||||
return true;
|
||||
}
|
||||
if (c == '{') {
|
||||
uriVar = true;
|
||||
continue;
|
||||
}
|
||||
if (c == '}' && uriVar) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -679,4 +679,14 @@ public class AntPathMatcherTests {
|
|||
"/*.html.hotel.*", pathMatcher.combine("/*.html", "hotel.*"));
|
||||
}
|
||||
|
||||
@Test // gh-22959
|
||||
public void isPattern() {
|
||||
assertTrue(pathMatcher.isPattern("/test/*"));
|
||||
assertTrue(pathMatcher.isPattern("/test/**/name"));
|
||||
assertTrue(pathMatcher.isPattern("/test?"));
|
||||
assertTrue(pathMatcher.isPattern("/test/{name}"));
|
||||
assertFalse(pathMatcher.isPattern("/test/name"));
|
||||
assertFalse(pathMatcher.isPattern("/test/foo{bar"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue