Commit 94c4b4d

Eric Bower  ·  2025-12-09 12:41:35 -0500 EST
parent 80b4959
fix: image request detection was matching anything instead of .jpg
2 files changed,  +3, -3
+1, -1
......@@ -404,7 +404,7 @@ func WebPerm(proj *db.Project) bool {
404404 return proj.Acl.Type == "public" || proj.Acl.Type == ""
405405 }
406406
407-var imgRegex = regexp.MustCompile("(.+.(?:jpg|jpeg|png|gif|webp|svg))(/.+)")
407+var imgRegex = regexp.MustCompile(`(.+\.(?:jpg|jpeg|png|gif|webp|svg))(/.+)`)
408408
409409 func (web *WebRouter) AssetRequest(perm func(proj *db.Project) bool) http.HandlerFunc {
410410 return func(w http.ResponseWriter, r *http.Request) {
+2, -2
......@@ -989,8 +989,8 @@ func createSubdomainRoutes(staticRoutes []shared.Route) []shared.Route {
989989 routes,
990990 shared.NewRoute("GET", "/raw/(.+)", postRawHandler),
991991 shared.NewRoute("GET", "/(.+).md", postRawHandler),
992- shared.NewRoute("GET", "/(.+.(?:jpg|jpeg|png|gif|webp|svg|ico))/(.+)", imgRequest),
993- shared.NewRoute("GET", "/(.+.(?:jpg|jpeg|png|gif|webp|svg|ico))$", imgRequest),
992+ shared.NewRoute("GET", `/(.+\.(?:jpg|jpeg|png|gif|webp|svg|ico))/(.+)`, imgRequest),
993+ shared.NewRoute("GET", `/(.+\.(?:jpg|jpeg|png|gif|webp|svg|ico))$`, imgRequest),
994994 shared.NewRoute("GET", "/(.+).html", postHandler),
995995 shared.NewRoute("GET", "/(.+)", postHandler),
996996 )