From 07d2fa579e035540626131ade5da610dc94ccdcf Mon Sep 17 00:00:00 2001 From: e-halinen <54105602+e-halinen@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:29:14 +0200 Subject: [PATCH] AB#46862: Refactor route filtering logic (#425) --- src/util/domain.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/util/domain.js b/src/util/domain.js index 605fd29a..71c45a3b 100644 --- a/src/util/domain.js +++ b/src/util/domain.js @@ -296,16 +296,19 @@ function routeGeneralizer(routes) { function filterRoute(props) { const { filter } = props; const { routeId } = props; + const routeIdParsed = trimRouteId(routeId); if (!filter) { return true; } - for (let i = 0; i < filter.length; i++) { - const char = filter[i]; - if (char !== '*' && char === routeId[i]) { - return false; + + const filteredRoutes = filter.split(',').map(routeIdToFilter => routeIdToFilter.trim()); + let routeMatchesFilter = false; + filteredRoutes.forEach(filterRouteId => { + if (routeId.includes(filterRouteId) && filterRouteId === routeIdParsed) { + routeMatchesFilter = true; } - } - return true; + }); + return !routeMatchesFilter; } export {