Skip to main content

sanitizeFilenameComponent

FitFileViewer - API Documentation v29.4.0


FitFileViewer - API Documentation / utils/files/sanitizeFilename / sanitizeFilenameComponent

Function: sanitizeFilenameComponent()

sanitizeFilenameComponent(value: string, fallback?: string): string

Defined in: utils/files/sanitizeFilename.js:106

Safely transforms an arbitrary string into a file-system friendly segment. Reserved Windows characters, ASCII control codes (0x00-0x1F), trailing dots and leading periods are stripped. Whitespace collapses to single underscores.

Parameters​

value​

string

Original label that needs to become file-name safe.

fallback?​

string = DEFAULT_FALLBACK_BASE

Replacement when the input sanitises to nothing.

Returns​

string

Sanitised file name component without an extension.