sanitizeFileExtension
FitFileViewer - API Documentation v29.9.0
FitFileViewer - API Documentation / utils/files/sanitizeFilename / sanitizeFileExtension
Function: sanitizeFileExtension()
sanitizeFileExtension(
extension:string,fallback?:string):string
Defined in: utils/files/sanitizeFilename.js:94
Normalises file extensions by removing leading dots/whitespace and any characters that are not alphanumeric, dashes or underscores. Extensions are lower-cased for consistency.
Parametersβ
extensionβ
string
Raw file extension (with or without leading dot).
fallback?β
string = ""
Optional fallback extension when sanitisation
empties the value. Default is ""
Returnsβ
string
A safe extension without leading dots. Empty string when sanitisation fails.