MCPcopy Index your code
hub / github.com/coder/coder / NormalizeStoredFileName

Function NormalizeStoredFileName

coderd/x/chatfiles/mime.go:92–101  ·  view source on GitHub ↗

NormalizeStoredFileName trims surrounding whitespace, strips control characters, and truncates the name to the durable storage byte limit without splitting UTF-8 runes.

(name string)

Source from the content-addressed store, hash-verified

90// characters, and truncates the name to the durable storage byte limit
91// without splitting UTF-8 runes.
92func NormalizeStoredFileName(name string) string {
93 name = strings.Map(func(r rune) rune {
94 if unicode.IsControl(r) {
95 return -1
96 }
97 return r
98 }, name)
99 name = strings.TrimSpace(name)
100 return truncateUTF8Bytes(name, MaxStoredFileNameBytes)
101}
102
103// PrepareStoredFile normalizes the display name, rejects empty normalized
104// names, and classifies the file bytes using detectName when provided, so

Callers 2

PrepareStoredFileFunction · 0.85
PrepareRecordingArtifactFunction · 0.85

Calls 1

truncateUTF8BytesFunction · 0.85

Tested by

no test coverage detected