Consistently handle match with '*' and trailing slash

Prior to this commit, the `AntPathMatcher` would inconsistently match
pattern with trailing slashes if they contain `"**"` within their
pattern.

For example `"/en/test/"` would match `"/**/test"`, but it would not
match `"/*/test"` (as it should).

This commit fixes this behavior for better consistency.

Fixes gh-27506
This commit is contained in:
Brian Clozel
2022-04-04 18:51:03 +02:00
parent 1776f08bfe
commit 705bf78104
2 changed files with 11 additions and 0 deletions
@@ -704,4 +704,11 @@ class AntPathMatcherTests {
assertThat(pathMatcher.isPattern(null)).isFalse();
}
@Test // gh-27506
void consistentMatchWithWildcardsAndTrailingSlash() {
assertThat(pathMatcher.match("/*/foo", "/en/foo")).isTrue();
assertThat(pathMatcher.match("/*/foo", "/en/foo/")).isFalse();
assertThat(pathMatcher.match("/**/foo", "/en/foo")).isTrue();
assertThat(pathMatcher.match("/**/foo", "/en/foo/")).isFalse();
}
}