Skip to content

Commit

Permalink
RequestMapper allows trailing characters
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Jan 24, 2022
1 parent 685d832 commit bf677b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ public RequestMatch<T> map(String path) {
params[paramCount] = null;
}
boolean fullMatch = matchPos == pathLength;
if (!prefixAllowed && !fullMatch) {
boolean doPrefixMatch = false;
if (!fullMatch) {
//according to the spec every template ends with (/.*)?
prefixAllowed = path.charAt(matchPos) == '/' && matchPos == pathLength - 1;
doPrefixMatch = (matchPos == 1 || path.charAt(matchPos) == '/') //matchPos == 1 corresponds to '/' as a root level match
&& (prefixAllowed || matchPos == pathLength - 1); //if prefix is allowed, or the remainder is only a trailing /
}
if (matched && (fullMatch || prefixAllowed)) {
if (matched && (fullMatch || doPrefixMatch)) {
String remaining;
if (fullMatch) {
remaining = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public void accept(ResteasyReactiveDeploymentManager.ScanStep scanStep) {
@Test
public void testRestPath() {
RestAssured.basePath = "/";
RestAssured.when().get("/foo/hello").then().statusCode(200).body(Matchers.is("hello"));
RestAssured.when().get("/foo/hello/nested").then().statusCode(200).body(Matchers.is("world hello"));
RestAssured.when().get("/foo/helloX").then().statusCode(404);
RestAssured.when().get("/foo/hello").then().statusCode(200).body(Matchers.is("hello"));
}

@Test
Expand Down

0 comments on commit bf677b0

Please sign in to comment.