From ba97458edd843d2dd3ae6e3002634c22df98ef29 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Wed, 5 Jul 2023 17:54:39 +0800 Subject: [PATCH] feat: fix StaticFilter issue --- controllers/resource.go | 2 +- routers/static_filter.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/resource.go b/controllers/resource.go index 111bfe2c..b697c4d6 100644 --- a/controllers/resource.go +++ b/controllers/resource.go @@ -294,7 +294,7 @@ func (c *ApiController) UploadResource() { return } - _, applicationId := util.GetOwnerAndNameFromIdNoCheck(strings.TrimRight(fullFilePath, ".html")) + _, applicationId := util.GetOwnerAndNameFromIdNoCheck(strings.TrimSuffix(fullFilePath, ".html")) applicationObj, err := object.GetApplication(applicationId) if err != nil { c.ResponseError(err.Error()) diff --git a/routers/static_filter.go b/routers/static_filter.go index 99300f47..9d798f0b 100644 --- a/routers/static_filter.go +++ b/routers/static_filter.go @@ -55,7 +55,7 @@ func StaticFilter(ctx *context.Context) { path += urlPath } - path2 := strings.TrimLeft(path, "web/build/images/") + path2 := strings.TrimPrefix(path, "web/build/images/") if util.FileExist(path2) { makeGzipResponse(ctx.ResponseWriter, ctx.Request, path2) return