♻️ Safe strip slash prefix for static path
This commit is contained in:
parent
f8a6580444
commit
6fd916058d
2
main.go
2
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
|
// 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
|
// deep down to any page or it's resource which might be secured by middleware or something
|
||||||
// else.
|
// 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 {
|
if err == nil {
|
||||||
http.ServeContent(w, r, static.Name(), domain.ResourceModTime(static), static)
|
http.ServeContent(w, r, static.Name(), domain.ResourceModTime(static), static)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue