From ff8be5a0902d4fa462f6892f30493a4cbfc0f2d6 Mon Sep 17 00:00:00 2001 From: Ash Date: Wed, 17 Jul 2024 19:17:55 +0100 Subject: [PATCH] move a conditional to the handler --- server/routes/alerts-and-warnings.js | 6 ++---- server/routes/river-and-sea-levels.js | 4 ---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/server/routes/alerts-and-warnings.js b/server/routes/alerts-and-warnings.js index 8927d125a..eedf34064 100644 --- a/server/routes/alerts-and-warnings.js +++ b/server/routes/alerts-and-warnings.js @@ -108,10 +108,8 @@ module.exports = [{ method: 'GET', path: `/${route}`, handler: (request, h) => { - if (request.query.q) { - if (isLocationEngland(util.cleanseLocation(request.query.q))) { - return h.redirect(`/${route}`) - } + if (request.query.q && isLocationEngland(util.cleanseLocation(request.query.q))) { + return h.redirect(`/${route}`) } return routeHandler(request, h) diff --git a/server/routes/river-and-sea-levels.js b/server/routes/river-and-sea-levels.js index c6769893a..dad1e80d1 100644 --- a/server/routes/river-and-sea-levels.js +++ b/server/routes/river-and-sea-levels.js @@ -75,10 +75,6 @@ async function locationQueryHandler (request, h) { return h.view(route, { model: emptyResultsModel() }) } - if (isLocationEngland(location)) { - return h.redirect(`/${route}`) - } - const rivers = await request.server.methods.flood.getRiversByName(location) let places = await findPlaces(location)