From 5cdce6b4b4ed3772650d5b754edcd144a3f57015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Krzeslak?= Date: Thu, 22 Oct 2026 16:55:41 +0200 Subject: [PATCH] fix(converters): fix converter discovery and array sharing bugs --- src/converters/main.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/converters/main.ts b/src/converters/main.ts index 9c063e18..6abedfdc 100644 --- a/src/converters/main.ts +++ b/src/converters/main.ts @@ -259,6 +259,7 @@ async function mainConverter( converterObj?.properties?.to[key]?.includes(convertTo) ) { converterFunc = converterObj.converter; + converterName = name; break; } } @@ -299,6 +300,7 @@ const possibleTargets: Record> = {}; for (const converterName in properties) { const converterProperties = properties[converterName]?.properties; + if (!converterProperties) continue; for (const key in converterProperties.from) { @@ -310,7 +312,7 @@ for (const converterName in properties) { for (const ext of fromList) { if (!possibleTargets[ext]) possibleTargets[ext] = {}; - possibleTargets[ext][converterName] = toList; + possibleTargets[ext][converterName] = [...toList]; } } } @@ -319,15 +321,13 @@ export const getPossibleTargets = (from: string): Record => { const fromClean = normalizeFiletype(from); return possibleTargets[fromClean] || {}; -}; +} const possibleInputs: string[] = []; for (const converterName in properties) { const converterProperties = properties[converterName]?.properties; - if (!converterProperties) { - continue; - } + if (!converterProperties) continue; for (const key in converterProperties.from) { for (const extension of converterProperties.from[key] ?? []) { @@ -344,13 +344,11 @@ const allTargets: Record = {}; for (const converterName in properties) { const converterProperties = properties[converterName]?.properties; - if (!converterProperties) { - continue; - } + if (!converterProperties) continue; for (const key in converterProperties.to) { if (allTargets[converterName]) { - allTargets[converterName].push(...(converterProperties.to[key] || [])); + allTargets[converterName] = [...allTargets[converterName], ...(converterProperties.to[key] || [])]; } else { allTargets[converterName] = [...(converterProperties.to[key] || [])]; } @@ -365,13 +363,11 @@ const allInputs: Record = {}; for (const converterName in properties) { const converterProperties = properties[converterName]?.properties; - if (!converterProperties) { - continue; - } + if (!converterProperties) continue; for (const key in converterProperties.from) { if (allInputs[converterName]) { - allInputs[converterName].push(...(converterProperties.from[key] || [])); + allInputs[converterName] = [...allInputs[converterName], ...(converterProperties.from[key] || [])]; } else { allInputs[converterName] = converterProperties.from[key] || []; } @@ -386,4 +382,4 @@ export const getAllInputs = (converter: string) => { * @internal For testing only. Do not use in production. * Tests need direct access to cover all branches of converter discovery and chunking logic. */ -export { chunks, mainConverter }; +export { chunks, mainConverter }; \ No newline at end of file