Fix bookmark favicon selection in oEmbed fallback#28939
Conversation
Walkthrough
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/core/server/services/oembed/oembed-service.js (1)
568-568: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a regression test for the undefined-type fallback.
This fixes the right contract, but the supplied tests only cover the two halves separately (
fetchOembedDataFromUrl()returning bookmark data, andfetchBookmarkData(..., 'bookmark')preferring the standard favicon). A single test for the exact!typefallback path would lock this bug down.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ghost/core/core/server/services/oembed/oembed-service.js` at line 568, Add a regression test for the exact undefined-type fallback path in oembed-service.js: the current coverage splits the behavior across fetchOembedDataFromUrl() and fetchBookmarkData(), but it does not verify the branch where !type triggers fetchBookmarkData(url, body, 'bookmark'). Add a focused test around OEmbedService’s fallback logic to assert that an undefined oEmbed type resolves to bookmark data and still uses the standard favicon behavior, so this specific contract is locked down.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ghost/core/core/server/services/oembed/oembed-service.js`:
- Line 568: Add a regression test for the exact undefined-type fallback path in
oembed-service.js: the current coverage splits the behavior across
fetchOembedDataFromUrl() and fetchBookmarkData(), but it does not verify the
branch where !type triggers fetchBookmarkData(url, body, 'bookmark'). Add a
focused test around OEmbedService’s fallback logic to assert that an undefined
oEmbed type resolves to bookmark data and still uses the standard favicon
behavior, so this specific contract is locked down.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 34c66b35-e43d-46e9-a29d-96dc5c1d1a14
📒 Files selected for processing (1)
ghost/core/core/server/services/oembed/oembed-service.js
Hi @9larsons,
I tested the merged change and found that bookmark cards can still prefer Apple Touch Icons in the oEmbed fallback path.
The bookmark-specific favicon logic works when
fetchBookmarkDatais called withtype === 'bookmark', but the fallback path currently calls it with the original undefined type:That means pickFn does not enter the bookmark-specific branch and falls back to the previous Apple-first behavior.
This change passes
'bookmark'explicitly in that fallback path:data = await this.fetchBookmarkData(url, body, 'bookmark');