MCPcopy
hub / github.com/webpack/webpack / sanitizeFilename

Function sanitizeFilename

test/BenchmarkTestCases.benchmark.mjs:333–342  ·  view source on GitHub ↗

* @param {string} filename filename * @returns {string} sanitized filename

(filename)

Source from the content-addressed store, hash-verified

331 * @returns {string} sanitized filename
332 */
333function sanitizeFilename(filename) {
334 // Replace invalid filesystem characters with underscores
335 return filename
336 .replace(/[<>:"/\\|?*]/g, "_")
337 .replace(/[\u0000-\u001F\u0080-\u009F]/g, "_")
338 .replace(/^\.+/, "_")
339 .replace(/\.+$/, "_")
340 .replace(/\s+/g, "_")
341 .slice(0, 200); // Limit filename length
342}
343
344/**
345 * @param {string} name name

Callers 1

withProfilingFunction · 0.85

Calls 2

sliceMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected