Repository navigation
Resolve video URLs against the page and embed YouTube/Vimeo only with a video ID - #5889
Draft
Eugene (OEvgeny) wants to merge 5 commits into
Draft
Eugene (OEvgeny) wants to merge 5 commits into
Eugene (OEvgeny) wants to merge 5 commits into
Conversation
Collaborator
Author
|
TODO: Can we have snaps for this, so we don't break it? Also, dark-green video could work better in this case. |
Collaborator
Author
|
Done: the test now snapshots the video attachment, video card, and animation card with a relative URL, plus the player for an unparsable URL, using a dark green video (a player that cannot play is gray, so a loaded video stands out); the YouTube/Vimeo fallbacks load from the network, so they are asserted instead. |
added 5 commits
October 17, 2026 18:41
`VideoContent` parsed the URL with `new URL(src)` to detect YouTube and Vimeo links. Relative URLs (such as `/videos/intro.mp4`), protocol-relative URLs, and URLs that cannot be parsed made it throw while rendering, so the video attachment, or the whole video card or animation card, was replaced by an empty bubble. Resolve the URL against `document.baseURI`, the same as `<video src>` does, and fall back to `<video>` if it still cannot be parsed. Remove the `<a href>` parsing workaround for browsers without `URL`, which are no longer supported since Internet Explorer support ended in 4.16.0. Add the 2-second dark gray WebM test asset (same file as in #5887).
`VideoContent` embedded every YouTube and Vimeo URL, even without a video ID: `https://www.youtube.com/@Microsoft` has no `v` parameter, so the embed ID was `null` (prop validation failed in development builds and the bubble was empty), and `https://youtu.be/` or `https://vimeo.com/` were embedded with an empty ID. Without a video ID, play the URL in `<video>`, the same as any other URL that cannot be embedded. Rename the test to `video.url.html`, as it now covers more than relative URLs.
… green video in tests - Snapshot the video attachment, the video card, and the animation card with a relative URL, and the video attachment with a URL that cannot be parsed. - Use a uniform dark green test video, so a loaded video is distinguishable from a player that cannot play (gray). - YouTube and Vimeo URLs without a video ID load from the network, so their state is asserted instead of their look.
#5887 lays out the video of animation cards as a block, which removes the line gap below the video. The card is 4 pixels shorter.
Eugene (OEvgeny)
force-pushed
the
OEvgeny/fix-video-relative-url
branch
from
October 18, 2026 01:52
db0c765 to
873c215
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog Entry
Fixed
/videos/intro.mp4), protocol-relative, cannot be parsed, or is a YouTube or Vimeo URL without a video ID: the video URL is now resolved against the page, the same as images and audio, and YouTube and Vimeo videos are only embedded when the URL has a video ID, in PR #5889, by @OEvgenyDescription
VideoContentparses the video URL to detect YouTube and Vimeo links. It callednew URL(src)without a base URL, which throws for relative URLs, protocol-relative URLs (such as//www.youtube.com/watch?v=...), and URLs that cannot be parsed. The error boundary of the attachment caught the error, so the video, or the whole video card or animation card including its title and buttons, was replaced by an empty bubble. Images and audio with the same URLs render, because they pass the URL to the browser as-is.Also, YouTube and Vimeo URLs without a video ID were embedded anyway.
https://www.youtube.com/@Microsofthas novparameter, so the embed ID wasnull: development builds failed prop validation and showed an empty bubble, and production builds embed/embed/null.https://youtu.be/andhttps://vimeo.com/were embedded with an empty ID, and the Vimeo player shows an error page.The URL is now resolved against
document.baseURI, the same as the browser does for<video src>. If it still cannot be parsed, it is passed to<video>as-is. YouTube and Vimeo videos are only embedded when the URL has a video ID.Design
<video>, the same as images and audio.https://) now renders a<video>that fails to load, instead of an empty bubble.<video>, the same as any other URL that cannot be embedded (such ashttps://example.com/page). The player cannot play it, the same as today for other URLs that are not videos, instead of an empty bubble or an embed without a video.<a href>parsing workaround for browsers withoutURLis removed: Internet Explorer is not supported since 4.16.0, and other components, such as file attachments and card actions, already useURLwithout a workaround.attachment/forbiddenProtocol.html.openUrl,playVideo, and others) only allow absolute URLs with an allowed scheme./shorts/<id>,/embed/<id>, or/live/<id>, are not embedded, the same as before. They are now played in<video>, instead of failing prop validation in development builds, or embedding/embed/nullin production builds.__tests__/assets/dark-green-video.webm, a uniform dark green video (2 seconds, no audio track). A player that cannot play is gray, close to the dark gray video that the focus indicator tests use, so with dark green the snapshots tell a loaded video from a failed one.<video>with the URL, no<iframe>) instead of taking snapshots.Specific Changes
Attachment/VideoContent.tsx: parse the URL withnew URL(src, document.baseURI)insideonErrorResumeNext(), embed YouTube and Vimeo only when the URL has a video ID, and otherwise render<video>; removedparseURL()and its<a href>workaround__tests__/html2/attachment/video.url.html: a video attachment, a video card, and an animation card with a relative URL each show a<video>that loads, and the cards keep their title; video attachments with a URL that cannot be parsed, or with a YouTube or Vimeo URL without a video ID, show a<video>and nothing is embedded__tests__/assets/dark-green-video.webm(1.2 KB, 2 seconds, solid dark green), byte-identical to the file in Let keyboard users reach the native controls of audio and video players in an activity #5891, so the two PRs do not conflict on itCHANGELOG.mdReview Checklist
z-index)package.jsonandpackage-lock.jsonreviewed