Ensure correct recognition for start of match-the-rest path elements

Without this change the /{*foobar} and /** path elements were
not correctly enforcing that the first character they encounter
must be a separator. This problem was introduced when adjusting
the generated path element chains for these constructs. Originally
the generated chain included a SeparatorPathElement but in order for
these to match 'nothing' (i.e. /foo matches /foo/{*foobar}) the separator
path element was removed, so the separator enforcement needed moving
into the CaptureTheRestPathElement and WildcardTheRestPathElement.

Issue: SPR-14544
This commit is contained in:
Andy Clement
2017-01-10 17:24:47 -08:00
committed by Brian Clozel
parent f58ffad939
commit f786feb5e1
3 changed files with 21 additions and 0 deletions

View File

@@ -79,6 +79,11 @@ public class PathPatternMatcherTests {
@Test
public void captureTheRest() {
checkMatches("/resource/{*foobar}", "/resource");
checkNoMatch("/resource/{*foobar}", "/resourceX");
checkNoMatch("/resource/{*foobar}", "/resourceX/foobar");
checkMatches("/resource/{*foobar}", "/resource/foobar");
checkCapture("/resource/{*foobar}", "/resource/foobar", "foobar", "/foobar");
checkCapture("/customer/{*something}", "/customer/99", "something", "/99");
checkCapture("/customer/{*something}", "/customer/aa/bb/cc", "something",
"/aa/bb/cc");
@@ -124,6 +129,11 @@ public class PathPatternMatcherTests {
checkMatches("a/*","a/");
checkMatches("a/*","a/a");
checkNoMatch("a/*","a/a/");
checkMatches("/resource/**", "/resource");
checkNoMatch("/resource/**", "/resourceX");
checkNoMatch("/resource/**", "/resourceX/foobar");
checkMatches("/resource/**", "/resource/foobar");
}
@Test