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("/:postID.gifv", pages.HandleGifv)
app.Get("/:baseName.:extension", pages.HandleMedia)
app.Get("/stack/:baseName.:extension", pages.HandleMedia)
app.Get("/:postID", pages.HandlePost)
app.Get("/:postID/embed", pages.HandleEmbed)
app.Get("/a/:postID", pages.HandlePost)

View File

@ -11,7 +11,11 @@ import (
func HandleMedia(c *fiber.Ctx) error {
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"))
}
}
func HandleUserCover(c *fiber.Ctx) error {