File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,8 +55,20 @@ const dateGroups = Object.entries(groupedByDate);
5555
5656const flights = (post .data .flights || []).map (resolveFlightSchedule );
5757const normalizeFlightNo = (flightNo : string ) => flightNo .replace (/ [^ a-zA-Z0-9 ] / g , ' ' ).toUpperCase ();
58+ const flightAwareAirlineCodes: Record <string , string > = {
59+ KE: ' KAL' ,
60+ LJ: ' JNA' ,
61+ };
62+ const getFlightAwareFlightNo = (flightNo : string ) => {
63+ const normalizedFlightNo = normalizeFlightNo (flightNo );
64+ const match = normalizedFlightNo .match (/ ^ ([A-Z ] + )(\d. * )$ / );
65+ if (! match ) return normalizedFlightNo ;
66+
67+ const [, airlineCode, flightNumber] = match ;
68+ return ` ${flightAwareAirlineCodes [airlineCode ] || airlineCode }${flightNumber } ` ;
69+ };
5870const getFlightAwareUrl = (flightNo : string ) => (
59- ` https://www.flightaware.com/live/flight/${normalizeFlightNo (flightNo )} `
71+ ` https://www.flightaware.com/live/flight/${getFlightAwareFlightNo (flightNo )} `
6072);
6173const getFlightSearchUrl = (flight : typeof flights [number ]) => {
6274 const query = [
You can’t perform that action at this time.
0 commit comments