From a4904109e4bbbf88873253938602545c90a46296 Mon Sep 17 00:00:00 2001 From: 178inaba <178inaba@users.noreply.github.com> Date: Fri, 28 Apr 2017 02:29:11 +0900 Subject: [PATCH] Fix GetTimelineHashtag --- status.go | 9 +++++++-- status_test.go | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/status.go b/status.go index cf2f036..4c28b33 100644 --- a/status.go +++ b/status.go @@ -173,9 +173,14 @@ func (c *Client) GetTimelinePublic(ctx context.Context, isLocal bool) ([]*Status } // GetTimelineHashtag return statuses from tagged timeline. -func (c *Client) GetTimelineHashtag(ctx context.Context, tag string) ([]*Status, error) { +func (c *Client) GetTimelineHashtag(ctx context.Context, tag string, isLocal bool) ([]*Status, error) { + params := url.Values{} + if isLocal { + params.Set("local", "t") + } + var statuses []*Status - err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/timelines/tag/%s", (&url.URL{Path: tag}).EscapedPath()), nil, &statuses, nil) + err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/timelines/tag/%s", url.PathEscape(tag)), params, &statuses, nil) if err != nil { return nil, err } diff --git a/status_test.go b/status_test.go index a511afe..bfc4a41 100644 --- a/status_test.go +++ b/status_test.go @@ -374,11 +374,11 @@ func TestGetTimelineHashtag(t *testing.T) { ClientSecret: "bar", AccessToken: "zoo", }) - _, err := client.GetTimelineHashtag(context.Background(), "notfound") + _, err := client.GetTimelineHashtag(context.Background(), "notfound", false) if err == nil { t.Fatalf("should be fail: %v", err) } - tags, err := client.GetTimelineHashtag(context.Background(), "zzz") + tags, err := client.GetTimelineHashtag(context.Background(), "zzz", true) if err != nil { t.Fatalf("should not be fail: %v", err) }