WARN against invalid patterns with PathPatternParser
As of gh-24952, `PathPatternParser` will strictly reject patterns with `"**"` in the middle of them. `"**"` is only allowed at the end of the pattern for matching multiple path segments until the end of the path. Currently, if `"**"` is used in the middle of a pattern it will be considered as a single `"*"` instead. Rejecting such cases should clarify the situation. This commit prepares for that upcoming change and: * logs a warning message if such a case is used by an application * expands the MVC and WebFlux documentation about URI matching in general Closes gh-24958
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -414,6 +414,14 @@ public class PathPatternParserTests {
|
||||
assertThat(patterns.get(1)).isEqualTo(p2);
|
||||
}
|
||||
|
||||
@Test // Should be updated with gh-24952
|
||||
public void doubleWildcardWithinPatternNotSupported() {
|
||||
PathPatternParser parser = new PathPatternParser();
|
||||
PathPattern pattern = parser.parse("/resources/**/details");
|
||||
assertThat(pattern.matches(PathContainer.parsePath("/resources/test/details"))).isTrue();
|
||||
assertThat(pattern.matches(PathContainer.parsePath("/resources/projects/spring/details"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void separatorTests() {
|
||||
PathPatternParser parser = new PathPatternParser();
|
||||
|
||||
Reference in New Issue
Block a user