Affects: 6.0.9
The tests below are successful:
assertThat(pathMatcher.match("bla/test/*", "bla/test/")).isTrue();
assertThat(pathMatcher.match("**/test/", "bla/test/")).isTrue();
then the following test should be successful too but fails:
assertThat(pathMatcher.match("**/test/*", "bla/test/")).isTrue();
The issue is located in https://github.com/spring-projects/spring-framework/blob/e5ee369e70e0a8ca04437f502649b11171a1c741/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java#LL278C1-L281C1
A possible fix:
if (pattIdxEnd == (pattDirs.length - 1)) {
if (pattDirs[pattIdxEnd].equals("*") && path.endsWith(pathSeparator)) {
pattIdxEnd--;
continue;
}
if (pattern.endsWith(this.pathSeparator) != path.endsWith(this.pathSeparator)) {
return false;
}
}
Comment From: rstoyanchev
This is by design. A a single *
matches only the current segment. The trailing slash is the root of the next segment.