MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / extractFileExtension

Function extractFileExtension

packages/components/src/validator.ts:115–129  ·  view source on GitHub ↗
(filename: string)

Source from the content-addressed store, hash-verified

113 * @returns {string} The normalized extension (lowercase, without dot) or empty string
114 */
115const extractFileExtension = (filename: string): string => {
116 const filenameParts = filename.split('.')
117 if (filenameParts.length <= 1) {
118 return ''
119 }
120 let ext = filenameParts.pop()!.toLowerCase()
121 // Normalize common extension variations to match MIME type mappings
122 const extensionNormalizationMap: { [key: string]: string } = {
123 jpeg: 'jpg', // image/jpeg and image/jpg both map to 'jpg'
124 tif: 'tiff', // image/tiff and image/tif both map to 'tiff'
125 oga: 'ogg' // audio/ogg and audio/oga both map to 'ogg'
126 }
127 ext = extensionNormalizationMap[ext] ?? ext
128 return ext
129}
130
131/**
132 * Validates that file extension matches the declared MIME type

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected