From f1c058cbfc4a87c070bd4de059a6ab245e613063 Mon Sep 17 00:00:00 2001 From: video-prize-ranch Date: Fri, 30 Sep 2022 16:17:24 -0400 Subject: [PATCH] Support i.stack.imgur.com (#61) --- main.go | 1 + pages/media.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 441d6ec..8860b2f 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/pages/media.go b/pages/media.go index b77b19b..c43b971 100644 --- a/pages/media.go +++ b/pages/media.go @@ -11,7 +11,11 @@ import ( func HandleMedia(c *fiber.Ctx) error { c.Set("Cache-Control", "public,max-age=31557600") - return handleMedia(c, "https://i.imgur.com/" + c.Params("baseName") + "." + c.Params("extension")) + 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 {