MCPcopy Index your code
hub / github.com/massCodeIO/massCode / sanitizeCaptureName

Function sanitizeCaptureName

src/main/api/routes/captures.ts:149–173  ·  view source on GitHub ↗
(name: string, fallback: string)

Source from the content-addressed store, hash-verified

147}
148
149function sanitizeCaptureName(name: string, fallback: string): string {
150 let sanitized = Array.from(name)
151 .map(char =>
152 INVALID_CAPTURE_NAME_CHARS.has(char) || char.charCodeAt(0) <= 0x1F
153 ? ' '
154 : char,
155 )
156 .join('')
157 .replace(/\s+/g, ' ')
158 .trim()
159
160 sanitized = sanitized.replace(/^\.+/, '').replace(/\.+$/, '').trim()
161
162 if (!sanitized) {
163 sanitized = fallback
164 }
165
166 const issue = getEntryNameValidationIssue(sanitized)
167
168 if (issue?.code === 'windowsReserved') {
169 return `${sanitized} capture`
170 }
171
172 return issue ? fallback : sanitized
173}
174
175function resolveCaptureName(body: CaptureRequest, fallback: string): string {
176 const sourceTitle

Callers 1

getUniqueNameFunction · 0.85

Calls 1

Tested by

no test coverage detected