Skip to content

Commit

Permalink
Merge 478dc91 into f515718
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed May 14, 2019
2 parents f515718 + 478dc91 commit 92938d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
13 changes: 1 addition & 12 deletions mastodon.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"os"
"path"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -352,17 +351,7 @@ func getPaginationID(rawurl, key string) (ID, error) {
return "", err
}

val := u.Query().Get(key)
if val == "" {
return "", nil
}

id, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return "", err
}

return ID(fmt.Sprint(id)), nil
return ID(u.Query().Get(key)), nil
}

func (p *Pagination) toValues() url.Values {
Expand Down
8 changes: 4 additions & 4 deletions mastodon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ func TestNewPagination(t *testing.T) {
}

_, err = newPagination(`<http://example.com?min_id=abc>; rel="prev"`)
if err == nil {
t.Fatalf("should be fail: %v", err)
if err != nil {
t.Fatalf("should not be fail: %v", err)
}

pg, err := newPagination(`<http://example.com?max_id=123>; rel="next", <http://example.com?since_id=789>; rel="prev"`)
Expand All @@ -317,8 +317,8 @@ func TestGetPaginationID(t *testing.T) {
}

_, err = getPaginationID("http://example.com?max_id=abc", "max_id")
if err == nil {
t.Fatalf("should be fail: %v", err)
if err != nil {
t.Fatalf("should not be fail: %v", err)
}

id, err := getPaginationID("http://example.com?max_id=123", "max_id")
Expand Down

0 comments on commit 92938d2

Please sign in to comment.