A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.
JavaScript 3d-globecesiumflight-trackinggeospatialgeospatial-intelligencegisosintphotogrammetrysatellite-trackingspatial-intelligencewebglworldview
fix(tools): read an airline only from a callsign of seven characters or fewer
quanticsoul47727bf268ec4287
diff --git a/src/tools/queries/aviation.js b/src/tools/queries/aviation.jsindex 6a4cbd54e..fa2ff1172 100644--- a/src/tools/queries/aviation.js+++ b/src/tools/queries/aviation.js@@ -44,15 +44,17 @@ const GROUP_LABELS = Object.freeze({/*** The ICAO airline designator a callsign flies under: three letters, then a- * flight number that starts with a digit (SWA1234, UAL12A, BAW1). Registrations- * used as callsigns (N123AB, GABCD) have no designator.+ * flight number that starts with a digit, seven characters at most (SWA1234,+ * 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) {- const match = /^([A-Z]{3})\d[0-9A-Z]{0,4}$/.exec(- String(callsign ?? '')- .trim()- .toUpperCase(),- );+ const text = String(callsign ?? '')+ .trim()+ .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;}diff --git a/src/tools/queries/aviation.test.mjs b/src/tools/queries/aviation.test.mjsindex 721385ef7..32c1e02cd 100644--- a/src/tools/queries/aviation.test.mjs+++ b/src/tools/queries/aviation.test.mjs@@ -516,6 +516,10 @@ test('an airline designator is read from an ICAO flight callsign only', () => {['GABCD', null],['SWA', null],['SWAX123', null],+ ['SWA12345', null],+ ['RPC1234', null],+ ['CUT1240', null],+ ['CUB123', 'CUB'],['', null],[null, null],])