Skip to content

Commit

Permalink
feat: remove cast to prevent null from being incorrectly converted
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Smith committed Jan 12, 2024
1 parent 20b15cb commit 14c4d41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/handlers/schoolData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ export const lambdaHandler = async (): Promise<{ statusCode: number }> => {
const match = currentSchools.find((school) => school.urn === urn);
logger.info(`${easting} ${northing}`);

const [longitude, latitude] = convertEastingNorthingtoLatLng(
Number(easting),
Number(northing)
);
const [longitude, latitude] = convertEastingNorthingtoLatLng(easting, northing);

const entry = {
urn,
Expand Down
6 changes: 3 additions & 3 deletions src/shared/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const osgb =
const wgs84 = '+proj=longlat +datum=WGS84 +no_defs ';

export const convertEastingNorthingtoLatLng = (
easting: number,
northing: number
easting: number | string | null,
northing: number | string | null
): [number, number] => {
if (!easting || !northing || isNaN(easting) || isNaN(northing)) {
if (!easting || !northing || isNaN(Number(easting)) || isNaN(Number(northing))) {
return [0, 0];
}

Expand Down

0 comments on commit 14c4d41

Please sign in to comment.