import path from 'path';

export function detectFormat(filename: string): string {
  const ext = path.extname(filename || '').toLowerCase();

  if (!ext) return 'bin';

  const map: Record<string, string> = {
    '.zip': 'zip',
    '.7z': '7z',
    '.chd': 'chd',
  };

  return map[ext] ?? ext.replace(/^\./, '');
}

export default detectFormat;
