fix(converters): improve CSV header generation and FFMPEG argument parsing

This commit is contained in:
Jörg Krzeslak
2026-10-22 13:51:27 +02:00
parent 285d812f8e
commit a95effbc83
2 changed files with 9 additions and 7 deletions
+2 -2
View File
@@ -770,9 +770,9 @@ export async function convert(
}
// Parse FFMPEG_ARGS environment variable into array
const ffmpegArgs = process.env.FFMPEG_ARGS ? process.env.FFMPEG_ARGS.split(/\s+/) : [];
const ffmpegArgs = process.env.FFMPEG_ARGS ? process.env.FFMPEG_ARGS.split(/\s+/).filter(Boolean) : [];
const ffmpegOutputArgs = process.env.FFMPEG_OUTPUT_ARGS
? process.env.FFMPEG_OUTPUT_ARGS.split(/\s+/)
? process.env.FFMPEG_OUTPUT_ARGS.split(/\s+/).filter(Boolean)
: [];
return new Promise((resolve, reject) => {
+7 -5
View File
@@ -46,12 +46,14 @@ export function parseVCF(data: string): Record<string, string>[] {
export function toCSV(data: Record<string, string>[]): string {
if (!data.length) return "";
const first = data[0];
if (!first) return "";
const headers = Object.keys(first);
const headers = new Set<string>();
for (const row of data) {
Object.keys(row).forEach((key) => headers.add(key));
}
const headerArray = Array.from(headers);
const escape = (str: string) => `"${str.replace(/"/g, '""')}"`;
const rows = data.map((row) => headers.map((h) => escape(row[h] || "")).join(","));
return [headers.join(","), ...rows].join("\n");
const rows = data.map((row) => headerArray.map((h) => escape(row[h] || "")).join(","));
return [headerArray.join(","), ...rows].join("\n");
}
export async function convert(