24 lines · 858 B · TypeScript
RawDownload
const VIDEO_MIME_TYPE_BY_EXTENSION = new Map([  ["avi", "video/x-msvideo"],  ["m4v", "video/mp4"],  ["mkv", "video/x-matroska"],  ["mov", "video/quicktime"],  ["mp4", "video/mp4"],  ["ogv", "video/ogg"],  ["webm", "video/webm"],]); export const VIDEO_FILE_EXTENSIONS = Object.freeze([...VIDEO_MIME_TYPE_BY_EXTENSION.keys()]); /** Recognizes videos even when the file picker omitted their MIME type. */export function videoMimeType(attachment: {  readonly name: string;  readonly mimeType: string;}): string | null {  const mimeType = attachment.mimeType.split(";", 1)[0]?.trim().toLowerCase() ?? "";  if (mimeType.startsWith("video/")) return mimeType;  const dotIndex = attachment.name.lastIndexOf(".");  return dotIndex < 0    ? null    : (VIDEO_MIME_TYPE_BY_EXTENSION.get(attachment.name.slice(dotIndex + 1).toLowerCase()) ?? null);}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t