godcrm/utils/fileHelpers.ts
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

28 lines
972 B
TypeScript

/**
* File type detection helpers
* Extracted from AIChatPanel.tsx (lines 132-153)
*/
/** Get file extension from URL or filename */
export const getFileExtension = (urlOrName: string): string => {
const parts = urlOrName.split('/').pop()?.split('.') || [];
return parts.length > 1 ? parts.pop()?.toLowerCase() || '' : '';
};
/** Check if file is an image */
export const isImageFile = (urlOrName: string): boolean => {
const ext = getFileExtension(urlOrName);
return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp', 'ico'].includes(ext);
};
/** Check if file is a video */
export const isVideoFile = (urlOrName: string): boolean => {
const ext = getFileExtension(urlOrName);
return ['mp4', 'webm', 'ogg', 'mov', 'avi', 'mkv'].includes(ext);
};
/** Check if file is audio */
export const isAudioFile = (urlOrName: string): boolean => {
const ext = getFileExtension(urlOrName);
return ['mp3', 'wav', 'flac', 'ogg', 'aac', 'm4a'].includes(ext);
};