diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js index 7010dac83..0089de87c 100644 --- a/lib/actions/apiV2.js +++ b/lib/actions/apiV2.js @@ -862,7 +862,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) { config?.modes?.initialState?.enabledModeButtons || {} - const strictModes = config?.itinerary?.strictItineraryFiltering + const strictModes = !!config?.itinerary?.strictItineraryFiltering // Filter mode definitions based on active mode keys const activeModeButtons = config.modes?.modeButtons.filter((mb) => @@ -968,7 +968,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) { let filteredItineraries = itineraries // If "strictItineraryFiltering" is enabled, only return itineraries that contain at least one explicitly requested mode... if (strictModes) { - filteredItineraries = itineraries.filter((itin) => + filteredItineraries = itineraries?.filter((itin) => itin.legs.some((leg) => activeModeStrings.includes(SIMPLIFICATIONS[leg.mode]) ) @@ -977,7 +977,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) { } // Filter itineraries to collapse short names and hide unnecessary errors. - const withCollapsedShortNames = filteredItineraries.map( + const withCollapsedShortNames = filteredItineraries?.map( (itin) => ({ ...itin, legs: itin.legs