Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Jan 4, 2024
1 parent d49b4a8 commit 264779e
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 264779e

Please sign in to comment.