Skip to content

Commit

Permalink
Preserve leading slash when resolving static paths (#111)
Browse files Browse the repository at this point in the history
Fixes #101
  • Loading branch information
lihaoyi authored Jan 4, 2024
1 parent e7c8373 commit 469dd0c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cask/src/cask/endpoints/StaticEndpoints.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import cask.router.{HttpEndpoint, Result}
import cask.model.Request
object StaticUtil{
def makePathAndContentType(t: String, ctx: Request) = {
val path = (cask.internal.Util.splitPath(t) ++ ctx.remainingPathSegments)
val leadingSlash = if (t.startsWith("/")) "/" else ""
val path = leadingSlash + (cask.internal.Util.splitPath(t) ++ ctx.remainingPathSegments)
.filter(s => s != "." && s != "..")
.mkString("/")
val contentType = java.nio.file.Files.probeContentType(java.nio.file.Paths.get(path))
Expand Down

0 comments on commit 469dd0c

Please sign in to comment.