| 199 | } |
| 200 | |
| 201 | function tryExpandURL(tcoUrl: string, extendedEntities: any): string { |
| 202 | // search through the url entities in a tweet to try and turn a t.co url into a full url |
| 203 | if (extendedEntities?.urls) { |
| 204 | for (const entity of extendedEntities.urls) { |
| 205 | if (entity.url === tcoUrl) |
| 206 | return entity.expanded_url; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | // no luck |
| 211 | return tcoUrl; |
| 212 | } |
| 213 | |
| 214 | export function convertCard(card: Record<string, any>, extendedEntities: any): Record<string, any> { |
| 215 | const pollMatch = card.name.match(/^poll(\d+)choice/); |