api/create-filename: build & sanitize filenames in one place

This commit is contained in:
wukko
2024-11-24 18:12:21 +06:00
parent 407c27ed86
commit 6770738116
9 changed files with 25 additions and 34 deletions

View File

@@ -1,5 +1,3 @@
const forbiddenCharsString = ['}', '{', '%', '>', '<', '^', ';', ':', '`', '$', '"', "@", '=', '?', '|', '*'];
export function convertMetadataToFFmpeg(obj) {
const keys = Object.keys(obj);
const tags = [
@@ -19,14 +17,6 @@ export function convertMetadataToFFmpeg(obj) {
return commands;
}
export function cleanString(string) {
for (const i in forbiddenCharsString) {
string = string.replaceAll("/", "_").replaceAll("\\", "_")
.replaceAll(forbiddenCharsString[i], '')
}
return string;
}
export function getRedirectingURL(url) {
return fetch(url, { redirect: 'manual' }).then((r) => {
if ([301, 302, 303].includes(r.status) && r.headers.has('location'))