Fix AntPathMatcher URI template variable extractor

See gh-33085
This commit is contained in:
tafjwr
2024-06-22 18:16:31 +09:00
committed by Brian Clozel
parent 9b58e1ff71
commit 83fcdfba64
2 changed files with 26 additions and 9 deletions

View File

@@ -41,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class AntPathMatcherTests {
private final AntPathMatcher pathMatcher = new AntPathMatcher();
private final AntPathMatcher dotSeparatedPathMatcher = new AntPathMatcher(".");
@Test
@@ -357,6 +358,24 @@ class AntPathMatcherTests {
assertThat(result).isEqualTo(expected);
}
@Test // gh-26264
void extractUriTemplateVariablesFromDotSeparatedPath() {
Map<String, String> result = dotSeparatedPathMatcher.extractUriTemplateVariables("price.stock.{tickerSymbol}", "price.stock.aaa");
assertThat(result).isEqualTo(Collections.singletonMap("tickerSymbol", "aaa"));
result = dotSeparatedPathMatcher.extractUriTemplateVariables("price.stock.{ticker/symbol}", "price.stock.aaa");
assertThat(result).isEqualTo(Collections.singletonMap("ticker/symbol", "aaa"));
result = dotSeparatedPathMatcher.extractUriTemplateVariables("notification.**.{operation}", "notification.foo.update");
assertThat(result).isEqualTo(Collections.singletonMap("operation", "update"));
result = dotSeparatedPathMatcher.extractUriTemplateVariables("news.sports.feed/{type}", "news.sports.feed/xml");
assertThat(result).isEqualTo(Collections.singletonMap("type", "xml"));
result = dotSeparatedPathMatcher.extractUriTemplateVariables("news.sports.{operation}/*", "news.sports.feed/xml");
assertThat(result).isEqualTo(Collections.singletonMap("operation", "feed"));
}
@Test
void extractUriTemplateVariablesRegex() {
Map<String, String> result = pathMatcher