Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/content/link-preview/content/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type DetectedVideo = {
url: string;
};

const VIDEO_EXTENSIONS = new Set([".mp4", ".webm", ".mov", ".m4v"]);
const VIDEO_EXTENSIONS = new Set([".mp4", ".webm", ".mov", ".m4v", ".m3u8"]);

function resolveAbsoluteUrl(candidate: string, baseUrl: string): string | null {
const trimmed = candidate.trim();
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/content/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const DIRECT_MEDIA_EXTENSIONS = [
"opus",
"aiff",
"wma",
"m3u8",
] as const;
const DIRECT_MEDIA_EXTENSION_SET = new Set<string>(DIRECT_MEDIA_EXTENSIONS);
const DIRECT_MEDIA_URL_PATTERN = new RegExp(
Expand Down
2 changes: 2 additions & 0 deletions src/media-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const resolveExtension = (filename: string | null, mediaType: string | null): st
if (normalized.includes("audio/flac")) return ".flac";
if (normalized.includes("video/mp4")) return ".mp4";
if (normalized.includes("video/webm")) return ".webm";
if (normalized.includes("application/vnd.apple.mpegurl") || normalized.includes("application/x-mpegurl"))
return ".m3u8";
return ".bin";
};

Expand Down
1 change: 1 addition & 0 deletions tests/content.url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe("content/url", () => {
expect(isDirectMediaUrl("https://example.com/voice.opus")).toBe(true);
expect(isDirectMediaUrl("https://example.com/clip.avi")).toBe(true);
expect(isDirectMediaUrl("https://example.com/track.wma#t=10")).toBe(true);
expect(isDirectMediaUrl("https://example.com/playlist.m3u8")).toBe(true);
expect(isDirectMediaUrl("https://example.com/article")).toBe(false);
});

Expand Down