(name: string, fallback: string)
| 147 | } |
| 148 | |
| 149 | function 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 | |
| 175 | function resolveCaptureName(body: CaptureRequest, fallback: string): string { |
| 176 | const sourceTitle |
no test coverage detected