Repository: vert-x3/vertx-web
Issue: Subrouter fails if mounted on another subrouter on path with path params

### Version

4.2.4 and 4.3.0-SNAPSHOT

### Context

If subrouter is NOT mounted on root router (but instead on another subrouter) and its path contains parameters, then routing fails with 404 and well-known HTML output "Resource not found".

### Do you have a reproducer?

By modifying [SubRouterTest#testSimpleWithParams](https://github.com/vert-x3/vertx-web/blob/8d1c667a6848ed71753d4dd7d314cb8492fb09a2/vertx-web/src/test/java/io/vertx/ext/web/SubRouterTest.java#L460) I constructed test that fails:

```
  @Test // Fails!
  public void testHierarchicalWithParams() throws Exception {

    Router restRouter = Router.router(vertx);
    Router subRouter = Router.router(vertx);

    subRouter.get("/files").handler(ctx -> {
      // version is extracted from the root router
      assertEquals("1", ctx.pathParam("version"));
      ctx.response().end();
    });

    restRouter.mountSubRouter("/:version", subRouter);

    router.mountSubRouter("/rest", restRouter);

    testRequest(HttpMethod.GET, "/rest/1/files", 200, "OK");
  }
```

Another interesting fact is that subrouter will work if it has path params too (!):

```
  @Test // Passes
  public void testHierarchicalWithParamsInAllRouters() throws Exception {

    Router restRouter = Router.router(vertx);
    Router subRouter = Router.router(vertx);

    subRouter.get("/files/:id").handler(ctx -> {
      // version is extracted from the root router
      assertEquals("1", ctx.pathParam("version"));
      // id is extracted from this router
      assertEquals("2", ctx.pathParam("id"));
      ctx.response().end();
    });

    restRouter.mountSubRouter("/:version", subRouter);

    router.mountSubRouter("/rest", restRouter);

    testRequest(HttpMethod.GET, "/rest/1/files/2", 200, "OK");
  }
```
### Steps to reproduce

1. Add those tests to [SubRouterTest.java](https://github.com/vert-x3/vertx-web/blob/master/vertx-web/src/test/java/io/vertx/ext/web/SubRouterTest.java)
2. Run tests with `mvn -Dtest=SubRouterTest test -pl vertx-web`

### Extra

* OS: Ubuntu 21:10
* JVM: OpenJDK 11.0.13 2021-10-19


Changed files:
vertx-web/src/test/java/io/vertx/ext/web/SubRouterTest.java, vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java

diff --git a/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java b/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java
index efae8cccd..63db497d3 100644
--- a/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java
+++ b/vertx-web/src/main/java/io/vertx/ext/web/impl/RouterImpl.java
@@ -346,12 +346,14 @@ public class RouterImpl implements Router {
     }
     // regex
     if (ctx.matchRest != -1) {
+      // if we're on a sub router already we need to skip the matched path
+      int skip = ctx.mountPoint != null ? ctx.mountPoint.length() : 0;
       if (ctx.matchNormalized) {
-        return ctx.normalizedPath().substring(0, ctx.matchRest);
+        return ctx.normalizedPath().substring(skip, skip + ctx.matchRest);
       } else {
         String path = ctx.request().path();
         if (path != null) {
-          return path.substring(0, ctx.matchRest);
+          return path.substring(skip, skip + ctx.matchRest);
         }
         return null;
       }
diff --git a/vertx-web/src/test/java/io/vertx/ext/web/SubRouterTest.java b/vertx-web/src/test/java/io/vertx/ext/web/SubRouterTest.java
index d0e6793e9..48700238a 100644
--- a/vertx-web/src/test/java/io/vertx/ext/web/SubRouterTest.java
+++ b/vertx-web/src/test/java/io/vertx/ext/web/SubRouterTest.java
@@ -647,5 +647,55 @@ public class SubRouterTest extends WebTestBase {
     router.route("/level1/*").handler(level2);
     testRequest(HttpMethod.GET, "/level1/level2/level3", 200, "ok");
   }
+
+  @Test
+  public void testHierarchicalWithParams() throws Exception {
+
+    Router restRouter = Router.router(vertx);
+    Router subRouter = Router.router(vertx);
+
+    subRouter.get("/files").handler(ctx -> {
+      // version is extracted from the root router
+      assertEquals("1", ctx.pathParam("version"));
+      ctx.response().end();
+    });
+
+    restRouter.mountSubRouter("/:version", subRouter);
+
+    router.mountSubRouter("/rest", restRouter);
+
+    // router
+    // /rest -> restRouter
+    //      /:version -> subRouter
+    //                    /files -> OK
+
+    testRequest(HttpMethod.GET, "/rest/1/files", 200, "OK");
+  }
+
+  @Test
+  public void testHierarchicalWithParamsInAllRouters() throws Exception {
+
+    Router restRouter = Router.router(vertx);
+    Router subRouter = Router.router(vertx);
+
+    subRouter.get("/files/:id").handler(ctx -> {
+      // version is extracted from the root router
+      assertEquals("1", ctx.pathParam("version"));
+      // id is extracted from this router
+      assertEquals("2", ctx.pathParam("id"));
+      ctx.response().end();
+    });
+
+    restRouter.mountSubRouter("/:version", subRouter);
+
+    router.mountSubRouter("/rest", restRouter);
+
+    // router
+    // /rest -> restRouter
+    //      /:version -> subRouter
+    //                    /files/:id -> OK
+
+    testRequest(HttpMethod.GET, "/rest/1/files/2", 200, "OK");
+  }
 }