Lowercases the input, strips non-alphanumeric characters (except spaces),
collapses whitespace to single underscores, trims leading/trailing
underscores, and truncates to maxLen characters.
Parameters
name: string
Raw title or label to sanitize.
maxLen: number = 40
Maximum length of the result (default 40).
Returns string
A filesystem-safe string, or an empty string if nothing remains.
Sanitize a string for use in a filename.
Lowercases the input, strips non-alphanumeric characters (except spaces), collapses whitespace to single underscores, trims leading/trailing underscores, and truncates to
maxLencharacters.