Skip to content

Commit

Permalink
Fix: Middleware.StaticServe crashes on empty path (#2517)
Browse files Browse the repository at this point in the history
  • Loading branch information
runtologist authored Nov 9, 2023
1 parent 735d9b7 commit 5bd1c22
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion zio-http/src/main/scala/zio/http/Middleware.scala
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ object Middleware extends HandlerAspects {
}

override def apply[Env1 <: Any, Err](routes: Routes[Env1, Err]): Routes[Env1, Err] = {
val mountpoint = Method.GET / path.segments.map(PathCodec.literal).reduceLeft(_ / _)
val mountpoint =
Method.GET / path.segments.map(PathCodec.literal).reduceLeftOption(_ / _).getOrElse(PathCodec.empty)
val pattern = mountpoint / trailing
val other = Routes(
pattern -> Handler
Expand Down

0 comments on commit 5bd1c22

Please sign in to comment.