MCPcopy Index your code
hub / github.com/simstudioai/sim / encodeFilenameForHeader

Function encodeFilenameForHeader

apps/sim/app/api/files/utils.ts:194–206  ·  view source on GitHub ↗
(storageKey: string)

Source from the content-addressed store, hash-verified

192}
193
194export function encodeFilenameForHeader(storageKey: string): string {
195 const filename = storageKey.split('/').pop() || storageKey
196
197 const hasNonAscii = /[^\x00-\x7F]/.test(filename)
198
199 if (!hasNonAscii) {
200 return `filename="${filename}"`
201 }
202
203 const encodedFilename = encodeURIComponent(filename)
204 const asciiSafe = filename.replace(/[^\x00-\x7F]/g, '_')
205 return `filename="${asciiSafe}"; filename*=UTF-8''${encodedFilename}`
206}
207
208export function createFileResponse(file: FileResponse): NextResponse {
209 const { contentType, disposition } = getSecureFileHeaders(file.filename, file.contentType)

Callers 4

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
createFileResponseFunction · 0.85

Calls 2

testMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected