Skip to content

Commit 469dd0c

Browse files
authored
Preserve leading slash when resolving static paths (#111)
Fixes #101
1 parent e7c8373 commit 469dd0c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cask/src/cask/endpoints/StaticEndpoints.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import cask.router.{HttpEndpoint, Result}
44
import cask.model.Request
55
object StaticUtil{
66
def makePathAndContentType(t: String, ctx: Request) = {
7-
val path = (cask.internal.Util.splitPath(t) ++ ctx.remainingPathSegments)
7+
val leadingSlash = if (t.startsWith("/")) "/" else ""
8+
val path = leadingSlash + (cask.internal.Util.splitPath(t) ++ ctx.remainingPathSegments)
89
.filter(s => s != "." && s != "..")
910
.mkString("/")
1011
val contentType = java.nio.file.Files.probeContentType(java.nio.file.Paths.get(path))

0 commit comments

Comments
 (0)