mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix(tools): read an airline only from a callsign of seven characters or fewer
ICAO flight-plan Item 7 caps aircraft identification at seven characters, so the flight number after the designator is one to four characters, not five. Philippine RP-C1234 and Cuban CU-T1240 registrations read like a designator plus a flight number once the hyphen is dropped; they now count as unknown. Cubana's CUB123 still counts as CUB. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
661e1d7fa3
commit
7bf268ec42
2 files changed
+13
-7
No files matched your search
@@ -44,15 +44,17 @@ const GROUP_LABELS = Object.freeze({
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The ICAO airline designator a callsign flies under: three letters, then a
|
* The ICAO airline designator a callsign flies under: three letters, then a
|
||||||
* flight number that starts with a digit (SWA1234, UAL12A, BAW1). Registrations
|
* flight number that starts with a digit, seven characters at most (SWA1234,
|
||||||
* used as callsigns (N123AB, GABCD) have no designator.
|
* UAL12A, BAW1). Registrations used as callsigns (N123AB, GABCD) have no
|
||||||
|
* designator; Philippine RP-C1234 and Cuban CU-T1240, which read like one
|
||||||
|
* without their hyphen, are excluded too.
|
||||||
*/
|
*/
|
||||||
export function airlineDesignator(callsign) {
|
export function airlineDesignator(callsign) {
|
||||||
const match = /^([A-Z]{3})\d[0-9A-Z]{0,4}$/.exec(
|
const text = String(callsign ?? '')
|
||||||
String(callsign ?? '')
|
.trim()
|
||||||
.trim()
|
.toUpperCase();
|
||||||
.toUpperCase(),
|
if (/^(?:RPC|CUT)\d{4}$/.test(text)) return null;
|
||||||
);
|
const match = /^([A-Z]{3})\d[0-9A-Z]{0,3}$/.exec(text);
|
||||||
return match ? match[1] : null;
|
return match ? match[1] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -516,6 +516,10 @@ test('an airline designator is read from an ICAO flight callsign only', () => {
|
|||||||
['GABCD', null],
|
['GABCD', null],
|
||||||
['SWA', null],
|
['SWA', null],
|
||||||
['SWAX123', null],
|
['SWAX123', null],
|
||||||
|
['SWA12345', null],
|
||||||
|
['RPC1234', null],
|
||||||
|
['CUT1240', null],
|
||||||
|
['CUB123', 'CUB'],
|
||||||
['', null],
|
['', null],
|
||||||
[null, null],
|
[null, null],
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in new issue
Block a user