refactor: split port diagnostics helpers

This commit is contained in:
Peter Steinberger
2026-01-08 02:42:25 +01:00
parent 2fe3b483b1
commit 3d0156890c
12 changed files with 516 additions and 445 deletions

View File

@@ -0,0 +1,17 @@
export function parseKeyValueOutput(
output: string,
separator: string,
): Record<string, string> {
const entries: Record<string, string> = {};
for (const rawLine of output.split(/\r?\n/)) {
const line = rawLine.trim();
if (!line) continue;
const idx = line.indexOf(separator);
if (idx <= 0) continue;
const key = line.slice(0, idx).trim().toLowerCase();
if (!key) continue;
const value = line.slice(idx + separator.length).trim();
entries[key] = value;
}
return entries;
}