Fix ranking calendar images #57

This commit is contained in:
VnPower
2024-02-14 10:02:10 +07:00
parent abbd5c40cc
commit 130fbd52dd
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -34,6 +34,14 @@ func ProxyImageUrl(c *fiber.Ctx, s string) string {
return s
}
func ProxyImageUrlNoEscape(c *fiber.Ctx, s string) string {
proxy := GetImageProxy(c)
s = strings.ReplaceAll(s, `https://i.pximg.net`, "https://"+proxy)
// s = strings.ReplaceAll(s, `https:\/\/i.pximg.net`, "/proxy/i.pximg.net")
s = strings.ReplaceAll(s, `https://s.pximg.net`, "/proxy/s.pximg.net")
return s
}
func GetImageProxy(c *fiber.Ctx) string {
sess, err := Store.Get(c)
if err != nil {
+1 -1
View File
@@ -64,7 +64,7 @@ func GetRankingCalendar(c *fiber.Ctx, mode string, year, month int) (template.HT
for _, a := range n.Attr {
if a.Key == "data-src" {
// adds a new link entry when the attribute matches
links = append(links, session.ProxyImageUrl(c, a.Val))
links = append(links, session.ProxyImageUrlNoEscape(c, a.Val))
}
}
}