char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
1/** 2* Gets a display label for a file type from various input formats 3* 4* Handles: 5* - MIME types: 'application/pdf' → 'PDF' 6* - AttachmentType values: 'PDF', 'AUDIO' → 'PDF', 'AUDIO' 7* - File names: 'document.pdf' → 'PDF' 8* - Unknown: returns 'FILE' 9* 10* @param input - MIME type, AttachmentType value, or file name 11* @returns Formatted file type label (uppercase) 12*/ 13export function getFileTypeLabel ( input :string | undefined ) :string { 14if ( ! input ) return 'FILE' ; 15 16// Handle MIME types (contains '/') 17if ( input . includes ( '/' )) { 18const subtype = input . split ( '/' ). pop (); 19 20if ( subtype ) { 21// Handle special cases like 'vnd.ms-excel' → 'EXCEL' 22if ( subtype . includes ( '.' )) { 23return subtype . split ( '.' ). pop ()?. toUpperCase () || 'FILE' ; 24} 25 26return subtype . toUpperCase (); 27} 28} 29 30// Handle file names (contains '.') 31if ( input . includes ( '.' )) { 32const ext = input . split ( '.' ). pop (); 33 34if ( ext ) return ext . toUpperCase (); 35} 36 37// Handle AttachmentType or other plain strings 38return input . toUpperCase (); 39}