From 4d7c145bb6c6d04a20d94ecb4df160cfe6e0965c Mon Sep 17 00:00:00 2001 From: video-prize-ranch Date: Wed, 3 Jul 2024 08:54:16 -0400 Subject: [PATCH] Add support for new gallery link format --- pages/post.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pages/post.go b/pages/post.go index 8507878..1fc10fc 100644 --- a/pages/post.go +++ b/pages/post.go @@ -37,16 +37,21 @@ func HandlePost(c *fiber.Ctx) error { utils.SetHeaders(c) c.Set("X-Frame-Options", "DENY") + postId := c.Params("postID") + if strings.Contains(postId, "-") { + postId = postId[len(postId)-7:] + } + post, err := api.Album{}, error(nil) switch { case strings.HasPrefix(c.Path(), "/a"): - post, err = ApiClient.FetchAlbum(c.Params("postID")) + post, err = ApiClient.FetchAlbum(postId) case strings.HasPrefix(c.Path(), "/gallery"): - post, err = ApiClient.FetchPosts(c.Params("postID")) + post, err = ApiClient.FetchPosts(postId) case strings.HasPrefix(c.Path(), "/t"): - post, err = ApiClient.FetchPosts(c.Params("postID")) + post, err = ApiClient.FetchPosts(postId) default: - post, err = ApiClient.FetchMedia(c.Params("postID")) + post, err = ApiClient.FetchMedia(postId) } if err != nil && err.Error() == "ratelimited by imgur" { return utils.RenderError(c, 429) @@ -61,7 +66,7 @@ func HandlePost(c *fiber.Ctx) error { comments := []api.Comment{} if post.SharedWithCommunity { c.Set("Cache-Control", "public,max-age=604800") - comments, err = ApiClient.FetchComments(c.Params("postID")) + comments, err = ApiClient.FetchComments(postId) if err != nil { return err }