Skip to content

feat: preview instagram story links - #10

Merged
musingfox merged 2 commits into
mainfrom
feat/instagram-stories
Oct 15, 2026
Merged

musingfox merged 2 commits into
mainfrom
feat/instagram-stories

Conversation

@musingfox

@musingfox musingfox commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Instagram story links (/stories/<user>/<media id>) had no preview: the Worker did not route them, so crawlers got a 302 to Instagram, whose logged-out story page only carries the profile picture.
  • A story's media id, written in Instagram's base64 shortcode alphabet, is a shortcode the existing /p/<shortcode>/embed/captioned/ page answers to, so stories reuse the post pipeline and cache. og:url keeps the cleaned story URL.
  • /stories/highlights/<id> is excluded: a highlight id names a collection, not a media.

Test plan

  • bun run check (545 pass); each commit passes on its own
  • Fixture embed-Deg-53RDHbL.html saved from the real story embed, session tokens scrubbed
  • End to end on cf dev with a Discordbot UA: 200 with og:video 640×1136; /media/Deg-53RDHbL/1 302s to a cdninstagram mp4 that returns 200 video/mp4
  • Not added to scripts/smoke.sh: a story disappears after 24 hours, so the sample would rot. If the embed is gone after expiry, the request fails open to the story URL.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新功能
    • 支援在 Instagram 限時動態網址上顯示貼文預覽;若無法取得預覽,則保留原有的轉址行為。
    • 不支援的精選限時動態網址會清理後轉址。

musingfox and others added 2 commits October 15, 2026 23:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: musingfox/better-link/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f0eb35a5-c6a1-48fe-acdc-9670ae656eb1
📥 Commits

Reviewing files that changed from the base of the PR and between 73c4dd1 and 2002ddd.

⛔ Files ignored due to path filters: 1
  • test/fixtures/instagram/embed-Deg-53RDHbL.html is excluded by !test/fixtures/**
📒 Files selected for processing: 4
  • src/index.ts
  • src/instagram.ts
  • test/instagram.test.ts
  • test/worker.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

新增 Instagram 媒體 ID 轉 shortcode 的功能。爬蟲可將符合條件的 Story URL 路由至 Instagram Open Graph 處理;不符合條件的路徑維持既有重新導向流程。

Changes: Instagram Story 支援

Layer / File(s) Summary
媒體 ID 轉換與驗證
src/instagram.ts, test/instagram.test.ts
新增 shortcodeOfMediaId,將符合格式的正十進位媒體 ID 轉為 Instagram shortcode。測試涵蓋有效與無效 ID,並驗證 embed fixture 解析結果。
Story URL 解析與爬蟲路由
src/index.ts, test/worker.test.ts
新增路徑解析,將一般 Story URL 的媒體 ID 轉為 shortcode,並以索引 1 進入 Instagram Open Graph 處理。Highlight 與無法轉換的 ID 不進入此處理流程。測試涵蓋預覽、404 重新導向、Highlight 及瀏覽器重新導向。

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Crawler as Discord 爬蟲
  participant Resolver as instagramShortcode
  participant Converter as shortcodeOfMediaId
  participant OG as instagramOg
  Crawler->>Resolver: 傳入 Story URL
  Resolver->>Converter: 傳入媒體 ID
  Converter-->>Resolver: 回傳 shortcode 或 null
  Resolver-->>Crawler: 回傳 shortcode 與媒體索引
  Crawler->>OG: 傳入 shortcode 與媒體索引
Loading
Merge Risk: ⚪ Minimal · up to 2002d

Story previews follow the intended media-ID behavior, with no identified issue requiring a fix before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 標題「feat: preview instagram story links」直接描述此變更的主要內容:支援 Instagram Story 連結預覽。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@musingfox
musingfox merged commit c33cfc9 into main Oct 15, 2026
2 checks passed
@musingfox
musingfox deleted the feat/instagram-stories branch October 15, 2026 15:30
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.

1 participant