Skip to content

Commit 3684e67

Browse files
committed
update tests
1 parent c269a9b commit 3684e67

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

timeline_v2.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ func (result *result) parse() *Tweet {
5656
if result.QuotedStatusResult.Result != nil {
5757
tw.QuotedStatus = result.QuotedStatusResult.Result.parse()
5858
}
59-
tw.HTML = expandURLs(tw.HTML, legacy.Entities.URLs, legacy.ExtendedEntities.Media)
60-
tw.HTML = expandURLs(tw.Text, legacy.Entities.URLs, legacy.ExtendedEntities.Media)
6159
return tw
6260
}
6361

tweets_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestGetTweetWithVideo(t *testing.T) {
9292
Name: "X",
9393
PermanentURL: "https://twitter.com/X/status/1697304622749086011",
9494
Photos: nil,
95-
Text: "on iOS & Android, you can now swipe to reply when you slide into their DMs https://t.co/evuWpMfBxQ",
95+
Text: "on iOS & Android, you can now swipe to reply when you slide into their DMs https://pbs.twimg.com/amplify_video_thumb/1697304568550330368/img/BUlESpef6FmWV_j2.jpg",
9696
Timestamp: 1693503931,
9797
UserID: "783214",
9898
Username: "X",
@@ -125,7 +125,7 @@ func TestGetTweetWithMultiplePhotos(t *testing.T) {
125125
URL: "https://pbs.twimg.com/media/FeUJKuxXEAAa6t7.jpg",
126126
},
127127
},
128-
Text: "More ways to discover videos on Twitter are here!\n\nNow on iOS, videos on your timeline will open in our full screen immersive video player, where you can swipe up to keep discovering more content. https://t.co/XI2vM8DKXA",
128+
Text: "More ways to discover videos on Twitter are here!\n\nNow on iOS, videos on your timeline will open in our full screen immersive video player, where you can swipe up to keep discovering more content. https://pbs.twimg.com/media/FeUJKdnXEAEFe2j.jpg",
129129
Timestamp: 1664982561,
130130
UserID: "17874544",
131131
Username: "Support",
@@ -147,7 +147,7 @@ func TestGetTweetWithGIF(t *testing.T) {
147147
ID: "1517535384833605632",
148148
Name: "Support",
149149
PermanentURL: "https://twitter.com/Support/status/1517535384833605632",
150-
Text: "Video captions or no captions, it’s now easier to choose for some of you on iOS, and soon on Android.\n\nOn videos that have captions available, we’re testing the option to turn captions off/on with a new “CC” button. https://t.co/Q2Q2Wmr78U",
150+
Text: "Video captions or no captions, it’s now easier to choose for some of you on iOS, and soon on Android.\n\nOn videos that have captions available, we’re testing the option to turn captions off/on with a new “CC” button. https://pbs.twimg.com/tweet_video_thumb/FQ9eXEhXEAA-haj.jpg",
151151
Timestamp: 1650643604,
152152
UserID: "17874544",
153153
Username: "Support",
@@ -170,7 +170,7 @@ func TestGetTweetWithPhotoAndGIF(t *testing.T) {
170170
Name: "Spaces",
171171
PermanentURL: "https://twitter.com/XSpaces/status/1583186305722507265",
172172
Photos: []twitterscraper.Photo{{ID: "1583186295626539020", URL: "https://pbs.twimg.com/media/FfibjDwWIAwvbtJ.jpg"}},
173-
Text: "“we need to talk” \n\nirl vs on Spaces https://t.co/hrflPpbpif",
173+
Text: "“we need to talk” \n\nirl vs on Spaces https://pbs.twimg.com/tweet_video_thumb/FfibjDnWIBIt5fn.jpg",
174174
Timestamp: 1666296004,
175175
UserID: "1065249714214457345",
176176
Username: "XSpaces",
@@ -197,7 +197,7 @@ func TestTweetMentions(t *testing.T) {
197197
func TestQuotedAndReply(t *testing.T) {
198198
sample := &twitterscraper.Tweet{
199199
ConversationID: "1237110546383724547",
200-
HTML: "The Easiest Problem Everyone Gets Wrong <br><br>[new video] --&gt; <a href=\"https://youtu.be/ytfCdqWhmdg\">https://t.co/YdaeDYmPAU</a> <br><a href=\"https://t.co/iKu4Xs6o2V\"><img src=\"https://pbs.twimg.com/media/ESsZa9AXgAIAYnF.jpg\"/></a>",
200+
HTML: "The Easiest Problem Everyone Gets Wrong <br><br>[new video] --&gt; <a href=\"https://youtu.be/ytfCdqWhmdg\">https://youtu.be/ytfCdqWhmdg</a> <br><a href=\"https://t.co/iKu4Xs6o2V\"><img src=\"https://pbs.twimg.com/media/ESsZa9AXgAIAYnF.jpg\"/></a>",
201201
ID: "1237110546383724547",
202202
Likes: 485,
203203
Name: "Vsauce2",
@@ -208,7 +208,7 @@ func TestQuotedAndReply(t *testing.T) {
208208
}},
209209
Replies: 12,
210210
Retweets: 18,
211-
Text: "The Easiest Problem Everyone Gets Wrong \n\n[new video] --&gt; https://t.co/YdaeDYmPAU https://t.co/iKu4Xs6o2V",
211+
Text: "The Easiest Problem Everyone Gets Wrong \n\n[new video] --&gt; https://youtu.be/ytfCdqWhmdg https://pbs.twimg.com/media/ESsZa9AXgAIAYnF.jpg",
212212
Timestamp: 1583785113,
213213
URLs: []string{"https://youtu.be/ytfCdqWhmdg"},
214214
UserID: "978944851",
@@ -241,13 +241,13 @@ func TestQuotedAndReply(t *testing.T) {
241241
func TestRetweet(t *testing.T) {
242242
sample := &twitterscraper.Tweet{
243243
ConversationID: "1758837061786779942",
244-
HTML: "no ads, just bangers<br><br>aka your For You feed with Premium+<br><br>subscribe here → <a href=\"https://x.com/i/premium_sign_up\">https://t.co/APTO1t7kMk</a>",
244+
HTML: "no ads, just bangers<br><br>aka your For You feed with Premium+<br><br>subscribe here → <a href=\"https://x.com/i/premium_sign_up\">https://x.com/i/premium_sign_up</a>",
245245
ID: "1758837061786779942",
246246
URLs: []string{"https://x.com/i/premium_sign_up"},
247247
IsSelfThread: false,
248248
Name: "Premium",
249249
PermanentURL: "https://twitter.com/premium/status/1758837061786779942",
250-
Text: "no ads, just bangers\n\naka your For You feed with Premium+\n\nsubscribe here → https://t.co/APTO1t7kMk",
250+
Text: "no ads, just bangers\n\naka your For You feed with Premium+\n\nsubscribe here → https://x.com/i/premium_sign_up",
251251
Timestamp: 1708174407,
252252
UserID: "1399766153053061121",
253253
Username: "premium",

util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func parseLegacyTweet(user *legacyUser, tweet *legacyTweet) *Tweet {
308308
tw.HTML = reTwitterURL.ReplaceAllStringFunc(tw.HTML, func(tco string) string {
309309
for _, entity := range tweet.Entities.URLs {
310310
if tco == entity.URL {
311-
return fmt.Sprintf(`<a href="%s">%s</a>`, entity.ExpandedURL, tco)
311+
return fmt.Sprintf(`<a href="%s">%s</a>`, entity.ExpandedURL, entity.ExpandedURL)
312312
}
313313
}
314314
for _, entity := range tweet.ExtendedEntities.Media {

0 commit comments

Comments
 (0)