From 5cbf96f3795155949430cbce8064c154c1ef388e Mon Sep 17 00:00:00 2001 From: Alessio Date: Sun, 5 May 2024 11:59:58 -0700 Subject: [PATCH] Fix unusual bug when scraping tweets which only happens if the tweet has a link and the text is exactly 22 chars long --- pkg/scraper/api_types.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/scraper/api_types.go b/pkg/scraper/api_types.go index 2d668cf..c748f06 100644 --- a/pkg/scraper/api_types.go +++ b/pkg/scraper/api_types.go @@ -202,6 +202,10 @@ func (t *APITweet) NormalizeContent() { // Handle short links showing up at ends of tweets for _, url := range t.Entities.URLs { index := strings.Index(t.FullText, url.ShortenedUrl) + if index < 0 { + // It's not in the text + continue + } if index == (len(t.FullText) - len(url.ShortenedUrl)) { t.FullText = strings.TrimSpace(t.FullText[0:index]) }