mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 22:29:38 +00:00
Added better invalid character replacements
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<table class="ui stackable selectable single fixed line striped compact small table">
|
||||
<!-- TODO: maybe have some of these tags customizable? E.g. small/large/compact/padded -->
|
||||
<!-- TODO: maybe make add the sortable class? -->
|
||||
<!-- TODO: maybe add the sortable class? -->
|
||||
<!-- TODO: learn semantic themes in order to change the $mobileBreakpoint global variable (better search table adjustment) -->
|
||||
<thead>
|
||||
<!-- NOTE: it would be nice to make this header sticky, but Fomantic-UI doesn't currently support that -->
|
||||
|
||||
@@ -11,7 +11,7 @@ export class SearchService {
|
||||
private resultsChangedEmitter = new EventEmitter<SongResult[]>() // For when any results change
|
||||
private newResultsEmitter = new EventEmitter<SongResult[]>() // For when a new search happens
|
||||
private results: SongResult[] = []
|
||||
private awaitingResults = false // TODO: add loading icon below table when this is true
|
||||
private awaitingResults = false
|
||||
private currentQuery: SongSearch
|
||||
private _allResultsVisible = true
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { AnyFunction } from '../../shared/UtilFunctions'
|
||||
import { createWriteStream } from 'fs'
|
||||
import * as needle from 'needle'
|
||||
// TODO: replace needle with got (for cancel() method) (if before-headers event is possible?)
|
||||
// TODO: add download throttle library and setting
|
||||
import { googleTimer } from './GoogleTimer'
|
||||
import { DownloadError } from './ChartDownload'
|
||||
|
||||
|
||||
@@ -1,23 +1,30 @@
|
||||
import * as randomBytes from 'randombytes'
|
||||
const sanitize = require('sanitize-filename')
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type AnyFunction = (...args: any) => any
|
||||
|
||||
/**
|
||||
* @returns `filename`, but with any invalid filename characters replaced with similar valid characters.
|
||||
* @returns `filename` with all invalid filename characters replaced.
|
||||
*/
|
||||
export function sanitizeFilename(filename: string): string {
|
||||
const newName = sanitize(filename, {
|
||||
const newFilename = sanitize(filename, {
|
||||
replacement: ((invalidChar: string) => {
|
||||
switch (invalidChar) {
|
||||
case '/': return '-'
|
||||
case '\\': return '-'
|
||||
case '<': return '❮'
|
||||
case '>': return '❯'
|
||||
case ':': return '꞉'
|
||||
case '"': return "'"
|
||||
default: return '_' // TODO: add more cases for replacing invalid characters
|
||||
case '/': return '/'
|
||||
case '\\': return '⧵'
|
||||
case '|': return '⏐'
|
||||
case '?': return '?'
|
||||
case '*': return '⁎'
|
||||
default: return '_'
|
||||
}
|
||||
})
|
||||
})
|
||||
return newName
|
||||
return (newFilename == '' ? randomBytes(5).toString('hex') : newFilename)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user