debut refacto
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { basename } from 'path'
|
||||
|
||||
/**
|
||||
* Sanitize a filename: strip path components, replace special chars,
|
||||
* collapse underscores, lowercase.
|
||||
*/
|
||||
export function sanitizeFilename(name: string): string {
|
||||
return basename(name)
|
||||
.replace(/[^a-zA-Z0-9._-]/g, '_')
|
||||
.replace(/_{2,}/g, '_')
|
||||
.toLowerCase()
|
||||
}
|
||||
Reference in New Issue
Block a user