diff --git a/server/armeria-server/src/main/scala/sttp/tapir/server/armeria/ArmeriaServerRequest.scala b/server/armeria-server/src/main/scala/sttp/tapir/server/armeria/ArmeriaServerRequest.scala index ec2190ebfa..bb95fd9e66 100644 --- a/server/armeria-server/src/main/scala/sttp/tapir/server/armeria/ArmeriaServerRequest.scala +++ b/server/armeria-server/src/main/scala/sttp/tapir/server/armeria/ArmeriaServerRequest.scala @@ -38,12 +38,8 @@ private[armeria] final case class ArmeriaServerRequest(ctx: ServiceRequestContex override def underlying: Any = ctx override val pathSegments: List[String] = { - // ctx.path() always starts with '/'. - if (ctx.path() == "/") { - Nil - } else { - ctx.path().substring(1).split("/").toList - } + val segments = uri.pathSegments.segments.map(_.v).filter(_.nonEmpty).toList + if (segments == List("")) Nil else segments // representing the root path as an empty list } override val queryParameters: QueryParams = { diff --git a/server/tests/src/main/scala/sttp/tapir/server/tests/ServerBasicTests.scala b/server/tests/src/main/scala/sttp/tapir/server/tests/ServerBasicTests.scala index 544c8d4773..b457ca3e64 100644 --- a/server/tests/src/main/scala/sttp/tapir/server/tests/ServerBasicTests.scala +++ b/server/tests/src/main/scala/sttp/tapir/server/tests/ServerBasicTests.scala @@ -461,6 +461,12 @@ class ServerBasicTests[F[_], OPTIONS, ROUTE]( (backend, baseUri) => basicRequest.get(uri"$baseUri/api").send(backend).map(_.code shouldBe StatusCode.Ok) }, + testServer(in_path_paths_out_header_body, "Encoded path should be decoded") { case (i, paths) => + pureResult(Right((i, paths.last))) + }{ + (backend, baseUri) => + basicRequest.get(uri"$baseUri/api/15/and/MIN%2FMAX").send(backend).map(_.body shouldBe Right("MIN/MAX")) + }, testServer(in_single_path, "single path should match single/ path")((_: Unit) => pureResult(Either.right[Unit, Unit](()))) { (backend, baseUri) => basicRequest.get(uri"$baseUri/api/").send(backend).map(_.code shouldBe StatusCode.Ok)