From 4f3ce6fc9dec8ae561bc1d614a75526183c10c02 Mon Sep 17 00:00:00 2001 From: Saturn225 <101260782+Saturn225@users.noreply.github.com> Date: Tue, 1 Oct 2024 01:46:17 +0530 Subject: [PATCH] Update RoutePattern.scala --- zio-http/shared/src/main/scala/zio/http/RoutePattern.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zio-http/shared/src/main/scala/zio/http/RoutePattern.scala b/zio-http/shared/src/main/scala/zio/http/RoutePattern.scala index 52c475f16d..7bcdff3505 100644 --- a/zio-http/shared/src/main/scala/zio/http/RoutePattern.scala +++ b/zio-http/shared/src/main/scala/zio/http/RoutePattern.scala @@ -53,7 +53,9 @@ final case class RoutePattern[A](method: Method, pathCodec: PathCodec[A]) { self * Returns a new pattern that is extended with the specified segment pattern. */ def /[B](that: PathCodec[B])(implicit combiner: Combiner[A, B]): RoutePattern[combiner.Out] = - copy(pathCodec = pathCodec ++ that) + if (that == PathCodec.empty) self.asInstanceOf[RoutePattern[combiner.Out]] + else if (pathCodec == PathCodec.empty) copy(pathCodec = that.asInstanceOf[PathCodec[combiner.Out]]) + else copy(pathCodec = pathCodec ++ that) /** * Creates a route from this pattern and the specified handler.