feat(web): derive video-embed provider and id from a pasted URL #104
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/deckle!104
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/97"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #97
What
Web-editor-only convenience for the
video-embedform: pasting a full YouTube or Vimeo URL into the Video ID field now derives the provider client-side — theproviderselect flips to the right value and the field reduces to the bare id. Anything that is not a recognized video URL is left exactly as typed. No sidecar, schema, or server changes; the stored content shape is identical, so nothing changes for agents, the server, or the shortcode.How
web/src/videoEmbed.ts(new): pureparseVideoEmbedUrl(raw)helper. Parses via WHATWGURL(retrying once with anhttps://prefix for scheme-less pastes), matches hosts exact-or-subdomain only, and extracts the id fromyoutube.com/watch?v=,youtu.be/,youtube.com/{shorts,embed,live}/,youtube-nocookie.com,vimeo.com/<id>, andplayer.vimeo.com/video/<id>. Query strings, fragments, and timestamps are dropped naturally; extracted ids are charset-validated (YouTube[A-Za-z0-9_-]{6,}, Vimeo digits). Bare ids fail the host match and returnnull.web/src/components/FormPane.tsx: 7-line hook inElementForm.update, guarded byschema.name === "video-embed" && name === "id". The raw write still happens first so the control re-syncs even when the same URL is pasted twice.web/src/test/VideoEmbed.test.tsx(new): 21 Vitest cases — pure-parser coverage of every listed form plus passthrough/garbage/empty inputs, and mounted-form tests assertingfield-id/field-providerbehavior, the double-paste edge, and the/api/page/savepayload.Verification
npm test: 41 files, 813 tests passed (full suite, no regressions);tsc --noEmitclean.go vet ./...,go test ./...(with hugo on PATH so nothing skips),go build— all green; frontend built withvite build.harness serve: pastedyoutube.com/watch?v=dQw4w9WgXcQinto the form → provider flipped to youtube, field reduced to the bare id; after save the markdown contains{{< video-embed id="dQw4w9WgXcQ" provider="youtube" … >}}and the rendered preview shows the click-to-load facade withdata-video-provider="youtube" data-video-id="dQw4w9WgXcQ". Repeated withvimeo.com/76979871(provider vimeo, numeric id, correct facade).scaffold/site/AGENTS.mdneeds no update: the change alters no sidecar schema, field type, or canonicalization rule it documents.🤖 Generated with Claude Code
Validation verdict: PASS.
Verification signal relied on: the green Forgejo Actions run
ci / build-and-test(success, 9m27s) — full Go and web suites, including the 21-caseVideoEmbed.test.tsx. Not re-run.Checked:
main; no conflict.feat(web): …); body carriesCloses #97onafk/97.videoEmbed.ts(new pure parser),FormPane.tsx(+8-line hook), and tests. No sidecar/schema/server/shortcode change — stored content shape identical (acceptance criterion).parseHttpUrlretries once with anhttps://prefix for scheme-less pastes and rejects non-http(s); YouTube coversyoutu.be,watch?v=,shorts/embed/live; Vimeo coversvimeo.com/<id>andplayer.vimeo.com/video/<id>. IDs are charset-validated; unrecognized input (incl. a bare id) returns null and is left untouched.isDomain), never a substring test.schema.name === "video-embed" && name === "id", writes the raw value first so a repeated paste re-syncs, and only overwrites on a match.scaffold/site/AGENTS.mdcorrectly not updated: no documented sidecar/field/canonicalization surface changed.No blockers. Awaiting a free-text merge go-ahead before merging.