Skip to content

refactor(preview): drop the dead YouTube iframe copy from the viewer - #388

Merged
PathGao merged 1 commit into
sftwrdotdev:masterfrom
PathGao:PathGao-claude/great-meninsky-192e5b
Aug 2, 2026
Merged

refactor(preview): drop the dead YouTube iframe copy from the viewer#388
PathGao merged 1 commit into
sftwrdotdev:masterfrom
PathGao:PathGao-claude/great-meninsky-192e5b

Conversation

@PathGao

@PathGao PathGao commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

MarkdownViewer.svelte still carried a pre-fix copy of the YouTube handling — isYoutubeLink, getYoutubeId and replaceWithYoutubeEmbed. The live implementation is in src/lib/utils/markdown.ts, where replaceWithYoutubeLink renders a thumbnail anchor that opens the system browser instead of an embed.

The copy was dead twice over:

  • No callers. grep -rn 'replaceWithYoutubeEmbed\|isYoutubeLink\|getYoutubeId\|video-container' src scripts matched only the definitions themselves.
  • Could not have worked if called. It builds an <iframe src="https://www.youtube.com/embed/...">, but frame-src is no longer in the app CSP (src-tauri/tauri.conf.json), so the frame cannot load at all.

Its isYoutubeLink had also drifted narrower than the live one, missing the youtube.com/embed/, /v/ and /u/ forms.

scripts/youtubeExternalFallback.test.ts asserts that createElement("iframe") is absent, but reads only markdown.ts — so this second copy sat outside the test's field of view.

No .video-container CSS exists anywhere in the repo, so nothing else went stale alongside it.

Verification

  • npm run check — 432 files, 0 errors, 0 warnings
  • npm test — 375 pass, 0 fail
  • cd src-tauri && cargo test — 98 pass, 0 fail

🤖 Generated with Claude Code

MarkdownViewer.svelte still carried a pre-fix copy of the YouTube
handling: isYoutubeLink, getYoutubeId and replaceWithYoutubeEmbed. The
live implementation lives in src/lib/utils/markdown.ts, which renders a
thumbnail anchor that opens the system browser instead of an embed.

The copy had no callers, and could not have worked if it did — it builds
an <iframe src="https://www.youtube.com/embed/..."> while frame-src is no
longer present in the app CSP, so the frame cannot load. Its
isYoutubeLink was also narrower than the live one, missing the
youtube.com/embed/, /v/ and /u/ forms.

youtubeExternalFallback.test.ts asserts that createElement("iframe") is
absent, but only reads markdown.ts, so this copy was invisible to it.

No .video-container CSS existed anywhere, so nothing else went stale
with it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@PathGao
PathGao merged commit 2e751d8 into sftwrdotdev:master Aug 2, 2026
4 checks passed
@PathGao
PathGao deleted the PathGao-claude/great-meninsky-192e5b branch August 2, 2026 21:27
PathGao added a commit that referenced this pull request Aug 2, 2026
#397 shipped the "YouTube links never become embedded frames" rule with
one allowlist entry for `replaceWithYoutubeEmbed` in
MarkdownViewer.svelte, an uncalled pre-fix leftover it could not delete
because #388 owned that file. Its comment said to delete the copy and
the entry together. #388 deleted the copy; the entry stayed, so the
marker now matches nothing and the meta-test that catches stale rules
fires - correctly.

The rule was always meant to be "allowed nowhere", which is now true.

Co-authored-by: PathGao <gaoyanbo@gaoyanbodeMacBook-Air.local>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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