Skip to content

Commit

Permalink
stable
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoulder4 committed Aug 21, 2023
1 parent f3c6957 commit 5f883be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion dist/src/findTrains.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ const findStationNameAndCode = (stationNameOrCode) => {
}
else {
stationName = stationNameOrCode;
stationCode = stationCodes["stations"].find(station => station["Station Name"] == stationNameOrCode)["CRS Code"];
const jsonMatch = stationCodes["stations"].find(station => station["Station Name"] == stationNameOrCode);
if (jsonMatch) {
stationCode = jsonMatch["CRS Code"];
}
else {
stationCode = null;
}
}
return { stationName, stationCode };
};
Expand Down
8 changes: 7 additions & 1 deletion src/findTrains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ export const findStationNameAndCode = (stationNameOrCode: string) => {
// console.log(`stationCode: ${stationCode}`);
} else {
stationName = stationNameOrCode;
stationCode = stationCodes["stations"].find(station=> station["Station Name"] == stationNameOrCode)["CRS Code"];
const jsonMatch = stationCodes["stations"].find(station=> station["Station Name"] == stationNameOrCode)
if (jsonMatch){
stationCode = jsonMatch["CRS Code"]
}
else{
stationCode = null;
}
}
return { stationName, stationCode };
};
Expand Down

0 comments on commit 5f883be

Please sign in to comment.