MCPcopy
hub / github.com/rollup/rollup / sanitizeFileName

Function sanitizeFileName

src/utils/sanitizeFileName.ts:6–13  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

4const DRIVE_LETTER_REGEX = /^[a-z]:/i;
5
6export 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}

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…