Support i.stack.imgur.com (#61)

This commit is contained in:
video-prize-ranch 2022-09-30 16:17:24 -04:00
parent b8d54dede6
commit f1c058cbfc
No known key found for this signature in database
GPG Key ID: D8EAA4C5B12A7281
2 changed files with 6 additions and 1 deletions

View File

@ -77,6 +77,7 @@ func main() {
app.Get("/privacy", pages.HandlePrivacy) app.Get("/privacy", pages.HandlePrivacy)
app.Get("/:postID.gifv", pages.HandleGifv) app.Get("/:postID.gifv", pages.HandleGifv)
app.Get("/:baseName.:extension", pages.HandleMedia) app.Get("/:baseName.:extension", pages.HandleMedia)
app.Get("/stack/:baseName.:extension", pages.HandleMedia)
app.Get("/:postID", pages.HandlePost) app.Get("/:postID", pages.HandlePost)
app.Get("/:postID/embed", pages.HandleEmbed) app.Get("/:postID/embed", pages.HandleEmbed)
app.Get("/a/:postID", pages.HandlePost) app.Get("/a/:postID", pages.HandlePost)

View File

@ -11,8 +11,12 @@ import (
func HandleMedia(c *fiber.Ctx) error { func HandleMedia(c *fiber.Ctx) error {
c.Set("Cache-Control", "public,max-age=31557600") c.Set("Cache-Control", "public,max-age=31557600")
if strings.HasPrefix(c.Path(), "/stack") {
return handleMedia(c, "https://i.stack.imgur.com/" + strings.ReplaceAll(c.Params("baseName"), "stack/", "") + "." + c.Params("extension"))
} else {
return handleMedia(c, "https://i.imgur.com/" + c.Params("baseName") + "." + c.Params("extension")) return handleMedia(c, "https://i.imgur.com/" + c.Params("baseName") + "." + c.Params("extension"))
} }
}
func HandleUserCover(c *fiber.Ctx) error { func HandleUserCover(c *fiber.Ctx) error {
c.Set("Cache-Control", "public,max-age=604800") c.Set("Cache-Control", "public,max-age=604800")