prevent loops of nothingness

This commit is contained in:
Laptop
2024-10-07 19:46:23 +03:00
parent 8eaafe6281
commit 46112fbca7

View File

@@ -182,6 +182,7 @@ func (p *Paginated[T]) Proceed() error {
req := fasthttp.AcquireRequest()
defer fasthttp.ReleaseRequest(req)
oldNext := p.Next
req.SetRequestURI(p.Next + "&client_id=" + cid)
req.Header.Set("User-Agent", cfg.UserAgent)
req.Header.Set("Accept-Encoding", "gzip, deflate, br, zstd")
@@ -203,7 +204,16 @@ func (p *Paginated[T]) Proceed() error {
data = resp.Body()
}
return cfg.JSON.Unmarshal(data, p)
err = cfg.JSON.Unmarshal(data, p)
if err != nil {
return err
}
if p.Next == oldNext { // prevent loops of nothingness
p.Next = ""
}
return nil
}
func TagListParser(taglist string) (res []string) {