diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java index b2baf6c67dc17..62b9c71d3f70d 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java @@ -104,11 +104,13 @@ public RequestMatch 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 = ""; diff --git a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/path/RestPathTestCase.java b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/path/RestPathTestCase.java index 4cbf79afa1fc0..e7261aeac94c9 100644 --- a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/path/RestPathTestCase.java +++ b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/path/RestPathTestCase.java @@ -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