Skip to content

Commit

Permalink
Reintroduce stop ID validation in estimates endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-vasconcelos committed Feb 13, 2025
1 parent 14f36ac commit 568abaf
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apps/server/src/endpoints/pips/estimates.endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ FASTIFY.server.post<RequestSchema>('/pips/estimates', async (request, reply) =>
return reply.code(400).send([]);
}

const regexPatternForStopId = /^\d{6}$/; // Match a string with exactly 6 numeric digits
const allStopIdsAreValid = request.body.stops.every(stopId => regexPatternForStopId.test(stopId));
if (!allStopIdsAreValid) {
return reply.code(400).send([]);
}

//
// Loop through each stop in the request to check for special cases

Expand Down Expand Up @@ -187,6 +181,12 @@ FASTIFY.server.post<RequestSchema>('/pips/estimates', async (request, reply) =>
}
}

const regexPatternForStopId = /^\d{6}$/; // Match a string with exactly 6 numeric digits
const allStopIdsAreValid = request.body.stops.every(stopId => regexPatternForStopId.test(stopId));
if (!allStopIdsAreValid) {
return reply.code(400).send([]);
}

//
// Request PCGI API for the estimated arrival times for the stops in the request

Expand Down

0 comments on commit 568abaf

Please sign in to comment.