Skip to content

Commit c07ef99

Browse files
committed
Fix bug for /assets* requests
1 parent 20e2150 commit c07ef99

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

modules/public/public.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func AssetsHandler(opts *Options) func(next http.Handler) http.Handler {
3636
if opts.Prefix == "" {
3737
opts.Prefix = "/"
3838
}
39+
if opts.Prefix != "/" {
40+
opts.Prefix = opts.Prefix + "/"
41+
}
3942

4043
return func(next http.Handler) http.Handler {
4144
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
@@ -54,10 +57,11 @@ func AssetsHandler(opts *Options) func(next http.Handler) http.Handler {
5457
resp.WriteHeader(http.StatusNotFound)
5558
return
5659
}
57-
if !strings.HasPrefix(file, "/") {
58-
next.ServeHTTP(resp, req)
60+
if strings.Contains(file, "\\") {
61+
resp.WriteHeader(http.StatusBadRequest)
5962
return
6063
}
64+
file = "/" + file
6165

6266
var written bool
6367
if opts.CorsHandler != nil {

0 commit comments

Comments
 (0)