From 790844039900a2737487576a5c4f39ce7023c0ff Mon Sep 17 00:00:00 2001 From: kumfo Date: Mon, 22 Jul 2024 14:39:59 +0800 Subject: [PATCH] fix(cdn): fix path replace --- cdn-aliyun/aliyun.go | 3 +++ cdn-s3/s3.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cdn-aliyun/aliyun.go b/cdn-aliyun/aliyun.go index 661de9d2..b3a22f19 100644 --- a/cdn-aliyun/aliyun.go +++ b/cdn-aliyun/aliyun.go @@ -305,6 +305,9 @@ func (c *CDN) rebuildReader(file io.Reader, replaceMap map[string]string) io.Rea if oldStr != "" { if newStr == "" { prefix := c.Config.VisitUrlPrefix + c.Config.ObjectKeyPrefix + if prefix[len(prefix)-1:] == "/" { + prefix = strings.TrimSuffix(prefix, "/") + } newStr = "\"" + prefix + "/static" } res = strings.ReplaceAll(res, oldStr, newStr) diff --git a/cdn-s3/s3.go b/cdn-s3/s3.go index 6835dde5..2d841955 100644 --- a/cdn-s3/s3.go +++ b/cdn-s3/s3.go @@ -296,6 +296,9 @@ func (c *CDN) rebuildReader(file io.Reader, replaceMap map[string]string) io.Rea if oldStr != "" { if newStr == "" { prefix := c.Config.VisitUrlPrefix + c.Config.ObjectKeyPrefix + if prefix[len(prefix)-1:] == "/" { + prefix = strings.TrimSuffix(prefix, "/") + } newStr = "\"" + prefix + "/static" } res = strings.ReplaceAll(res, oldStr, newStr)