-
Notifications
You must be signed in to change notification settings - Fork 556
Closed
Labels
Description
Version
4.4.0
Context
I encountered an some problems regarding path matching with path params and routes ending with /* while writing tests for an application that uses the vertx http-server and router:
- Some requests for paths that would match without path params do not match when path params are used
Do you have a reproducer?
New router tests in #2396
Steps to reproduce
Create the following Routes
router.route("/a/:id/b/:id2/c/*").handler(rc -> {
assertEquals("123", rc.pathParam("id"));
assertEquals("1234", rc.pathParam("id2"));
rc.response().end("r4");
});
router.route("/a/:id/b1/*").handler(rc -> {
assertEquals("123", rc.pathParam("id"));
rc.response().end("r3");
});
router.route("/a/:id/*").handler(rc -> {
assertEquals("123", rc.pathParam("id"));
rc.response().end("r2");
});
router.route("/:id/*").handler(rc -> {
assertEquals("123", rc.pathParam("id"));
rc.end("r1");
});Test against these routes
Working:
// should call "/:id/*"
testRequest(HttpMethod.GET, "/123/foo", 200, "OK", "r1");
testRequest(HttpMethod.GET, "/123/", 200, "OK", "r1");
// should call "/a/:id/*"
testRequest(HttpMethod.GET, "/a//123/", 200, "OK", "r2");
testRequest(HttpMethod.GET, "/a/123/foo/bar", 200, "OK", "r2");
// should call "/a/:id/b1/*"
testRequest(HttpMethod.GET, "/a//123/b1/", 200, "OK", "r3");
testRequest(HttpMethod.GET, "/a/123/b1/foo", 200, "OK", "r3");
// should call "/a/:id/b/:id2/c/*"
testRequest(HttpMethod.GET, "/a//123/b/1234/c/", 200, "OK", "r4");
testRequest(HttpMethod.GET, "/a/123/b/1234/c/foo", 200, "OK", "r4");404:
// should call "/:id/*"
testRequest(HttpMethod.GET, "/123", 200, "OK", "r1");
// should call "/a/:id/*"
testRequest(HttpMethod.GET, "/a/123", 200, "OK", "r2");
testRequest(HttpMethod.GET, "/a//123", 200, "OK", "r2");
// should call "/a/:id/b1/*"
testRequest(HttpMethod.GET, "/a/123/b1", 200, "OK", "r3");
testRequest(HttpMethod.GET, "/a//123//b1", 200, "OK", "r3");
// should call "/a/:id/b/:id2/c/*"
testRequest(HttpMethod.GET, "/a/123/b/1234/c", 200, "OK", "r4");Wrong handler called (problem with normalization?):
// called handler of route "/a/:id/*" instead of route "/a/:id/b/:id2/c/*"
testRequest(HttpMethod.GET, "/a//123//b//1234//c", 200, "OK", "r4");