Fix downloads

This commit is contained in:
Geomitron
2023-12-25 02:49:46 -06:00
parent ba309654ca
commit 99cfb306be
30 changed files with 557 additions and 1450 deletions

View File

@@ -1,5 +1,4 @@
import _ from 'lodash'
import sanitize from 'sanitize-filename'
import { Difficulty, Instrument } from 'scan-chart'
import { ChartData } from './interfaces/search.interface'
@@ -24,29 +23,6 @@ export function driveLink(fileId: string) {
return `https://drive.google.com/open?id=${fileId}`
}
/**
* @returns `filename` with all invalid filename characters replaced.
*/
export function sanitizeFilename(filename: string): string {
const newFilename = sanitize(filename, {
replacement: ((invalidChar: string) => {
switch (invalidChar) {
case '<': return ''
case '>': return ''
case ':': return ''
case '"': return "'"
case '/': return ''
case '\\': return ''
case '|': return '⏐'
case '?': return ''
case '*': return ''
default: return '_'
}
}),
})
return (newFilename === '' ? 'TODO_MAKE_UNIQUE' : newFilename)
}
/**
* @returns `text` converted to lower case.
*/