From 6fd916058d86ed2e59bfdba4d8a095e00a4759a5 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Mon, 13 Nov 2023 07:17:41 +0600 Subject: [PATCH] :recycle: Safe strip slash prefix for static path --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 7dbfdbc..998a2ec 100644 --- a/main.go +++ b/main.go @@ -105,7 +105,7 @@ func NewApp(ctx context.Context, config *domain.Config) (*App, error) { // INFO(toby3d): any static file is public by design, so it's safe to search it first before // deep down to any page or it's resource which might be secured by middleware or something // else. - static, err := statics.Get(r.Context(), r.URL.Path[1:]) + static, err := statics.Get(r.Context(), strings.TrimPrefix(r.URL.Path, "/")) if err == nil { http.ServeContent(w, r, static.Name(), domain.ResourceModTime(static), static)