Skip to content

Commit

Permalink
support assetserving of files with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Jun 10, 2020
1 parent c3f12af commit 178b167
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/examples/files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ const pkgfiles = route("pkg/:pkg", packagefiles(), Mux.notfound())
using AssetRegistry

function assetserve(dirs=true)
absdir(req) = AssetRegistry.registry["/assetserver/" * req[:params][:key]]
absdir(req) = AssetRegistry.registry["/assetserver/" * HTTP.unescapeuri(req[:params][:key])]
path(req) = HTTP.unescapeuri.(req[:path])
branch(req -> (isfile(absdir(req)) && isempty(req[:path])) ||
validpath(absdir(req), joinpath(req[:path]...), dirs=dirs),
req -> fresp(joinpath(absdir(req), req[:path]...)))
validpath(absdir(req), joinpath(path(req)...), dirs=dirs),
req -> fresp(joinpath(absdir(req), path(req)...)))
end

const assetserver = route("assetserver/:key", assetserve(), Mux.notfound())

0 comments on commit 178b167

Please sign in to comment.