Skip to content

Commit

Permalink
feat: expand description URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Oct 13, 2024
1 parent 033e860 commit 7fc6b8a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,27 @@ func parseProfile(user legacyUser) Profile {
return profile
}

func expandURLs(text string, urls []interface{}) string {
expandedText := text
for _, urlObj := range urls {
if urlMap, ok := urlObj.(map[string]interface{}); ok {
if shortURL, ok := urlMap["url"].(string); ok {
if expandedURL, ok := urlMap["expanded_url"].(string); ok {
expandedText = strings.ReplaceAll(expandedText, shortURL, expandedURL)
}
}
}
}
return expandedText
}

func parseProfileV2(user userResult) Profile {
u := user.Legacy
description := expandURLs(u.Description, u.Entities.Description.Urls)
profile := Profile{
Avatar: u.ProfileImageURLHTTPS,
Banner: u.ProfileBannerURL,
Biography: u.Description,
Biography: description,
FollowersCount: u.FollowersCount,
FollowingCount: u.FavouritesCount,
FriendsCount: u.FriendsCount,
Expand Down

0 comments on commit 7fc6b8a

Please sign in to comment.