MCPcopy
hub / github.com/simstudioai/sim / sanitizeFilenameForMetadata

Function sanitizeFilenameForMetadata

apps/sim/lib/uploads/utils/file-utils.ts:807–821  ·  view source on GitHub ↗
(filename: string)

Source from the content-addressed store, hash-verified

805 * and cannot contain certain special characters
806 */
807export function sanitizeFilenameForMetadata(filename: string): string {
808 return (
809 filename
810 // Remove non-ASCII characters (keep only printable ASCII 0x20-0x7E)
811 .replace(/[^\x20-\x7E]/g, '')
812 // Remove characters that are problematic in HTTP headers
813 .replace(/["\\]/g, '')
814 // Replace multiple spaces with single space
815 .replace(/\s+/g, ' ')
816 // Trim whitespace
817 .trim() ||
818 // Provide fallback if completely sanitized
819 'file'
820 )
821}
822
823/**
824 * Sanitize metadata values for storage providers

Callers 4

client.test.tsFile · 0.90
uploadToS3Function · 0.90
generateS3PresignedUrlFunction · 0.90

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected