cleaner tag parameters

This commit is contained in:
orangix 2023-08-17 12:38:37 +02:00
parent 5c3289d5db
commit 33f306472f
No known key found for this signature in database
GPG Key ID: C31D4A86601C8416
2 changed files with 7 additions and 6 deletions

View File

@ -69,10 +69,7 @@ func (client *Client) FetchTag(tag string, sort string, page string) (Tag, error
func(key, value gjson.Result) bool {
url, _ := url.Parse(strings.ReplaceAll(value.Get("url").String(), "https://imgur.com", ""))
q := url.Query()
q.Add("tag", tag)
q.Add("sort", sort)
q.Add("page", page)
q.Add("i", key.String())
q.Add("tag", tag+"."+sort+"."+page+"."+key.String())
url.RawQuery = q.Encode()
posts = append(posts, Submission{

View File

@ -80,8 +80,12 @@ func HandlePost(c *fiber.Ctx) error {
}
c.Set("Content-Security-Policy", csp)
tag, sort, page, index := c.Query("tag"), c.Query("sort"), c.Query("page"), c.Query("i")
next := nextInTag(ApiClient, tag, sort, page, index)
var next string
tagParam := strings.Split(c.Query("tag"), ".")
if len(tagParam) == 4 {
tag, sort, page, index := tagParam[0], tagParam[1], tagParam[2], tagParam[3]
next = nextInTag(ApiClient, tag, sort, page, index)
}
return c.Render("post", fiber.Map{
"post": post,