Skip to content

Commit 23a50b2

Browse files
authored
Merge pull request #95 from szporwolik/dev_fix_log4om
Fix for Log4OM - K_INDEX
2 parents f362481 + b8339b0 commit 23a50b2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

main.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,23 @@ function normalizeTxPwr(adifdata) {
320320
});
321321
}
322322

323+
function normalizeKIndex(adifdata) {
324+
return adifdata.replace(/<K_INDEX:(\d+)>([^<]+)/gi, (match, length, value) => {
325+
const numValue = parseFloat(value.trim());
326+
if (isNaN(numValue)) return ''; // Remove if not a number
327+
328+
// Round to nearest integer and clamp to 0-9 range
329+
let kIndex = Math.round(numValue);
330+
if (kIndex < 0) kIndex = 0;
331+
if (kIndex > 9) kIndex = 9;
332+
333+
return `<K_INDEX:${kIndex.toString().length}>${kIndex}`;
334+
});
335+
}
336+
323337
function manipulateAdifData(adifdata) {
324338
adifdata = normalizeTxPwr(adifdata);
339+
adifdata = normalizeKIndex(adifdata);
325340
// add more manipulation if necessary here
326341
// ...
327342
return adifdata;

0 commit comments

Comments
 (0)