feat(embeds): TikTok URL trim, SoundCloud on. + redd.it short links

- TikTok player URL trimmed to ?autoplay=1&rel=0 (the control params were all
  default-on no-ops).
- SoundCloud on.soundcloud.com share short links now embed (widget follows the
  redirect via w.soundcloud.com).
- redd.it short links now embed via embed.reddit.com/comments/<id>/ (the redirect
  target is reddit.com/comments/<id>, no subreddit needed).

No CSP change (hosts already allowlisted). Vimeo event/ondemand deferred — the
embed format/host couldn't be verified from a fake id and would need a CSP
change; leaving it for the review agents to research. Tests 21.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 00:32:09 -04:00
co-authored by Claude Opus 4.8
parent 3694a3612d
commit a28c305835
2 changed files with 22 additions and 10 deletions
+6 -2
View File
@@ -89,7 +89,7 @@ test('tiktokIdFromOembed + player url', () => {
assert.equal(tiktokIdFromOembed({ embed_product_id: '7659555276823006478' }), '7659555276823006478');
assert.equal(tiktokIdFromOembed({ html: '<blockquote data-video-id="123456">' }), '123456');
assert.equal(tiktokIdFromOembed({}), null);
assert.ok(tiktokPlayerEmbedUrl('999').startsWith('https://www.tiktok.com/player/v1/999?autoplay=1'));
assert.equal(tiktokPlayerEmbedUrl('999'), 'https://www.tiktok.com/player/v1/999?autoplay=1&rel=0');
});
test('Dailymotion + Streamable', () => {
@@ -132,9 +132,11 @@ test('Spotify target + height', () => {
assert.equal(spotifyEmbedHeight('album'), 352);
});
test('SoundCloud track detection', () => {
test('SoundCloud track detection (+ on. short link)', () => {
assert.equal(isSoundCloudTrack('https://soundcloud.com/artist/some-track'), true);
assert.equal(isSoundCloudTrack('https://soundcloud.com/artist'), false); // bare profile
assert.equal(isSoundCloudTrack('https://on.soundcloud.com/abc123'), true); // share short link
assert.equal(parseMediaEmbed('https://on.soundcloud.com/abc123', 'h')?.provider, 'soundcloud');
});
test('buildVideoEmbedUrl: cookie-less YouTube + Vimeo', () => {
@@ -218,6 +220,8 @@ test('Reddit post embed → redditmedia', () => {
);
assert.equal(getRedditPostEmbed('https://old.reddit.com/r/aww/comments/xyz/'), 'https://embed.reddit.com/r/aww/comments/xyz/?ref_source=embed&ref=share&embed=true&theme=dark');
assert.equal(getRedditPostEmbed('https://www.reddit.com/r/aww/'), null); // subreddit, not a post
// redd.it short link → comments-only embed (no subreddit in the redirect)
assert.equal(getRedditPostEmbed('https://redd.it/1abc23'), 'https://embed.reddit.com/comments/1abc23/?ref_source=embed&ref=share&embed=true&theme=dark');
});
test('parseMediaEmbed: Instagram/Reddit → rich, Tidal → audio', () => {