Skip to content

feat(extension): expand t.co links when importing tweets#1352

Open
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:feat/twitter-expand-tco-links
Open

feat(extension): expand t.co links when importing tweets#1352
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:feat/twitter-expand-tco-links

Conversation

@abhay-codes07

Copy link
Copy Markdown
Contributor

Motivation

A tweet's full_text embeds every link as an opaque https://t.co/xxxx shortlink. tweetToMarkdown wrote that text verbatim, so imported tweets stored https://t.co/abc123 instead of the real destination. That is hard to read, and worse for search/recall over the memory since the meaningful URL is gone. The real URL is already present on entities.urls (expanded_url + display_url); it just was not being used.

Change

Add a pure expandTweetText(text, urls) and run the tweet body through it in tweetToMarkdown:

markdown += `${expandTweetText(tweet.text, tweet.entities.urls)}\n\n`

It replaces each t.co shortlink in the text with a markdown link to the expanded URL, labelled with the human-readable display_url:

check this https://t.co/abc123 out
check this [example.com/article](https://example.com/article) out

Entries missing a url or expanded_url are left untouched, and repeated shortlinks are all expanded. Rendering as a markdown link stays consistent with the rest of the markdown this function already emits (images, bold, etc.).

Tests

twitter-expand-text.test.ts (bun:test): single link, multiple links with a repeat, display_url-empty fallback to the expanded URL, entries missing fields left untouched, and the no-op cases (no/empty url entities). 5 tests pass; extension tsc is clean for these files.

A tweet's full_text embeds every link as an opaque `https://t.co/xxxx`
shortlink, so imported tweets stored those instead of the real destinations,
which is bad for reading and for search/recall over the memory. The real URL is
already available on entities.urls (expanded_url + display_url), it just was not
being used.

Add expandTweetText, which rewrites each t.co shortlink in the text to a
markdown link pointing at the expanded URL and labelled with the human-readable
display_url, then run the tweet body through it in tweetToMarkdown. Entries
missing a url or expanded_url are left untouched. Adds unit tests for single,
repeated, and multiple links, the display_url fallback, and the no-op cases.
Copilot AI review requested due to automatic review settings July 24, 2026 06:32
@graphite-app graphite-app Bot added the extension related to Supermemory Chrome Extension label Jul 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension related to Supermemory Chrome Extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants