mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
Added better invalid character replacements
This commit is contained in:
10
package-lock.json
generated
10
package-lock.json
generated
@@ -2212,6 +2212,15 @@
|
|||||||
"integrity": "sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==",
|
"integrity": "sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/randombytes": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/randombytes/-/randombytes-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-bz8PhAVlwN72vqefzxa14DKNT8jK/mV66CSjwdVQM/k3Th3EPKfUtdMniwZgMedQTFuywAsfjnZsg+pEnltaMA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@types/rimraf": {
|
"@types/rimraf": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.0.tgz",
|
||||||
@@ -14468,7 +14477,6 @@
|
|||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
|
||||||
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
|
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.0"
|
"safe-buffer": "^5.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"needle": "^2.3.2",
|
"needle": "^2.3.2",
|
||||||
"node-7z": "^2.0.5",
|
"node-7z": "^2.0.5",
|
||||||
"node-unrar-js": "^0.8.1",
|
"node-unrar-js": "^0.8.1",
|
||||||
|
"randombytes": "^2.1.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rxjs": "~6.5.5",
|
"rxjs": "~6.5.5",
|
||||||
"sanitize-filename": "^1.6.3",
|
"sanitize-filename": "^1.6.3",
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
"@types/mv": "^2.1.0",
|
"@types/mv": "^2.1.0",
|
||||||
"@types/needle": "^2.0.4",
|
"@types/needle": "^2.0.4",
|
||||||
"@types/node": "^12.11.1",
|
"@types/node": "^12.11.1",
|
||||||
|
"@types/randombytes": "^2.0.0",
|
||||||
"@types/rimraf": "^3.0.0",
|
"@types/rimraf": "^3.0.0",
|
||||||
"@types/underscore": "^1.9.4",
|
"@types/underscore": "^1.9.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.19.2",
|
"@typescript-eslint/eslint-plugin": "^2.19.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<table class="ui stackable selectable single fixed line striped compact small table">
|
<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 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) -->
|
<!-- TODO: learn semantic themes in order to change the $mobileBreakpoint global variable (better search table adjustment) -->
|
||||||
<thead>
|
<thead>
|
||||||
<!-- NOTE: it would be nice to make this header sticky, but Fomantic-UI doesn't currently support that -->
|
<!-- 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 resultsChangedEmitter = new EventEmitter<SongResult[]>() // For when any results change
|
||||||
private newResultsEmitter = new EventEmitter<SongResult[]>() // For when a new search happens
|
private newResultsEmitter = new EventEmitter<SongResult[]>() // For when a new search happens
|
||||||
private results: SongResult[] = []
|
private results: SongResult[] = []
|
||||||
private awaitingResults = false // TODO: add loading icon below table when this is true
|
private awaitingResults = false
|
||||||
private currentQuery: SongSearch
|
private currentQuery: SongSearch
|
||||||
private _allResultsVisible = true
|
private _allResultsVisible = true
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { AnyFunction } from '../../shared/UtilFunctions'
|
|||||||
import { createWriteStream } from 'fs'
|
import { createWriteStream } from 'fs'
|
||||||
import * as needle from 'needle'
|
import * as needle from 'needle'
|
||||||
// TODO: replace needle with got (for cancel() method) (if before-headers event is possible?)
|
// 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 { googleTimer } from './GoogleTimer'
|
||||||
import { DownloadError } from './ChartDownload'
|
import { DownloadError } from './ChartDownload'
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,30 @@
|
|||||||
|
import * as randomBytes from 'randombytes'
|
||||||
const sanitize = require('sanitize-filename')
|
const sanitize = require('sanitize-filename')
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export type AnyFunction = (...args: any) => 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 {
|
export function sanitizeFilename(filename: string): string {
|
||||||
const newName = sanitize(filename, {
|
const newFilename = sanitize(filename, {
|
||||||
replacement: ((invalidChar: string) => {
|
replacement: ((invalidChar: string) => {
|
||||||
switch (invalidChar) {
|
switch (invalidChar) {
|
||||||
case '/': return '-'
|
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