Skip to content

Read a reddit short or share link as the feed of the post it opens - #121

Merged
only-cli merged 1 commit into
only-cli:mainfrom
kevin9327:fix/reddit-redirect-to-feed
Sep 28, 2026
Merged

only-cli merged 1 commit into
only-cli:mainfrom
kevin9327:fix/reddit-redirect-to-feed

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

oc open on a reddit short link or share link ends at the login wall, while the post URL it points at reads fine. Both are common in pasted links: redd.it/<id> short links, and the /r/<sub>/s/<code> links the reddit app's Share button makes.

$ oc open https://www.reddit.com/r/ClaudeAI/s/2p5qaMz4XN      (main)
oc: no readable content at https://www.reddit.com/r/ClaudeAI/comments/1v94nal/people_liked_my_desert_so_heres_a_waterbending/?share_id=...
    (no text on the whole page), so it is JavaScript-only, gated, or challenged; ...

$ oc open https://redd.it/1wsaolh                               (main)
oc: no readable content at https://www.reddit.com/comments/1wsaolh (~47 tokens of text out of ~41740 of HTML), ...

$ oc open https://www.reddit.com/r/ClaudeAI/s/2p5qaMz4XN      (branch)
# People liked my desert, so here's a waterbending demo! : ClaudeAI
## [1] People liked my desert, so here's a waterbending demo!
by /u/Any-Reputation8118, 2026-07-28

and https://redd.it/1wsaolh on the branch, hop by hop:

firefox 301 https://redd.it/1wsaolh
firefox 200 https://www.reddit.com/comments/1wsaolh/.rss

Cause. fetchPage (src/fetch.js) swaps a reddit.com page URL for its Atom feed when the session has no reddit cookies (#52, #59), but only for the URL as typed. Both link shapes answer with a 301 to the post page, and followRedirects followed that hop as is.

Change.

  • The swap moves into a small readableURL(url, jar), used for the first URL as before and, through a new rewrite option on followRedirects, for every redirect hop. Both transports pass it. The hop is rewritten before assertSafeTarget checks it, so the check still sees the URL that is actually fetched. A session with reddit cookies still gets the page it asked for, on every hop.
  • redd.it joins FIREFOX_FIRST_HOSTS. The identity is chosen once per redirect chain, and the reddit.com feed hop answered chrome with a 403 in my runs, so a short link that starts with chrome costs two more requests against reddit's rate limit before the firefox retry gets it.

Test. tests/fetch.test.js gains one test with a fake impers: a redd.it link that 301s to /comments/abc123 is fetched as /comments/abc123/.rss, and with a reddit.com cookie jar the hop is left as the page. On main it fails with asked ending in https://www.reddit.com/comments/abc123. identityOrder gains a redd.it assertion. Full suite on Windows (Node 24): 316 tests, 313 pass, 3 skipped, 0 fail.

Left alone. A redirect from a feed back to an HTML page would now be rewritten to the feed again and stop at the 20-hop limit rather than landing on the wall; reddit does not do that today, and either way the page is unreadable. No CHANGELOG line, to keep this round's PRs from conflicting there.

🤖 Generated with Claude Code

fetchPage swaps a reddit.com page URL for its Atom feed, since the HTML
page is a login wall for a reader with no cookies. It only looked at
the URL as typed. A redd.it short link and the app's /r/<sub>/s/<code>
share link are both a 301 to the post page, so the redirect landed on
the wall and oc reported no readable content, while the post URL they
point at reads fine.

The swap now runs on every redirect hop too, through followRedirects,
with the same rule: a logged-in session still gets the page. redd.it
also joins the firefox-first hosts: the identity is picked once for the
whole chain, and the reddit.com hop answers chrome with a 403, so
starting with chrome spent two extra requests against reddit's rate
limit on every short link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@only-cli
only-cli merged commit 7978ab2 into only-cli:main Sep 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants