fix(satellites): reject TLE pairs with mismatched catalog numbers (#906, #936)

This commit is contained in:
VG31OP committed 2026-10-13 16:57:55 +05:30
1 parent 8b8ccc9a81
commit 003b92f64a
3 files changed
+32 -7

No files matched your search

+11 -4
View File
@@ -13,7 +13,14 @@ export function parseTleText(text) {
const name = lines[i];
const line1 = lines[i + 1];
const line2 = lines[i + 2];
if (line1.startsWith('1 ') && line2.startsWith('2 ')) {
const cat1 = tleCatalogNumber(line1);
const cat2 = tleCatalogNumber(line2);
if (
line1.startsWith('1 ') &&
line2.startsWith('2 ') &&
cat1 !== null &&
cat1 === cat2
) {
result.push({ name, line1, line2 });
i += 2;
}
@@ -21,8 +28,8 @@ export function parseTleText(text) {
return result;
}
/** The NORAD catalog number from TLE line 1, or null. */
export function tleCatalogNumber(line1) {
const number = Number.parseInt(String(line1).slice(2, 7), 10);
/** The NORAD catalog number from a TLE line, or null. */
export function tleCatalogNumber(line) {
const number = Number.parseInt(String(line).slice(2, 7), 10);
return Number.isInteger(number) ? number : null;
}