(name: string)
| 4 | const DRIVE_LETTER_REGEX = /^[a-z]:/i; |
| 5 | |
| 6 | export function sanitizeFileName(name: string): string { |
| 7 | const match = DRIVE_LETTER_REGEX.exec(name); |
| 8 | const driveLetter = match ? match[0] : ''; |
| 9 | |
| 10 | // A `:` is only allowed as part of a windows drive letter (ex: C:\foo) |
| 11 | // Otherwise, avoid them because they can refer to NTFS alternate data streams. |
| 12 | return driveLetter + name.slice(driveLetter.length).replace(INVALID_CHAR_REGEX, '_'); |
| 13 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…