mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
7a7a9f5e6b
111 of 122 top-level src/utils/ files move into 16 topic folders (audio, cache, cover, share, server, playback, playlist, deviceSync, waveform, mix, format, export, changelog, ui, perf, componentHelpers). True singletons with no cluster stay at the utils/ root. Pure file-move: a path-aware codemod rewrote 539 relative-import specifiers across 275 files; no logic touched. The hot-path coverage gate list (.github/frontend-hot-path-files.txt) is updated to the new paths for the 11 gated utils files — a mechanical consequence of the move, not a CI change. tsc is green.
16 lines
660 B
TypeScript
16 lines
660 B
TypeScript
/**
|
|
* Make an arbitrary album / playlist name safe to use as a file name on
|
|
* Windows, macOS, and Linux. Replaces every reserved character class with
|
|
* a dash, collapses runs of dots (which Windows treats specially) into one,
|
|
* trims leading/trailing whitespace and dots, and caps the length at 200
|
|
* characters so we don't hit MAX_PATH edges on Windows. Falls back to
|
|
* `download` when the sanitisation strips the name down to nothing.
|
|
*/
|
|
export function sanitizeFilename(name: string): string {
|
|
return name
|
|
.replace(/[/\\?%*:|"<>]/g, '-')
|
|
.replace(/\.{2,}/g, '.')
|
|
.replace(/^[\s.]+|[\s.]+$/g, '')
|
|
.substring(0, 200) || 'download';
|
|
}
|