expand URL, fix #31

This commit is contained in:
Nicolas Constant 2021-01-13 23:57:48 -05:00
parent f7baa86d45
commit 1d584b0df3
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688
2 changed files with 10 additions and 1 deletions

View file

@ -45,6 +45,10 @@ namespace BirdsiteLive.Twitter.Extractors
message = message.Replace("RT", "[RT]");
}
// Expand URLs
foreach (var url in tweet.Urls.OrderByDescending(x => x.URL.Length))
message = message.Replace(url.URL, url.ExpandedURL);
return message;
}

View file

@ -43,11 +43,16 @@ namespace BirdsiteLive.Twitter
_statisticsHandler.CalledUserApi();
if (user == null) return null;
// Expand URLs
var description = user.Description;
foreach (var descriptionUrl in user.Entities?.Description?.Urls?.OrderByDescending(x => x.URL.Length))
description = description.Replace(descriptionUrl.URL, descriptionUrl.ExpandedURL);
return new TwitterUser
{
Acct = username,
Name = user.Name,
Description = user.Description,
Description = description,
Url = $"https://twitter.com/{username}",
ProfileImageUrl = user.ProfileImageUrlFullSize,
ProfileBackgroundImageUrl = user.ProfileBackgroundImageUrlHttps,