Skip to content

Commit

Permalink
fix(cdn): fix path replace
Browse files Browse the repository at this point in the history
  • Loading branch information
kumfo committed Jul 22, 2024
1 parent ecc12a7 commit 7908440
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cdn-aliyun/aliyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions cdn-s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7908440

Please sign in to comment.