@wemap/routers 11.8.4 → 11.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1386,7 +1386,17 @@ class IdfmRemoteRouter extends RemoteRouter {
1386
1386
  error: jsonResponse.error.message || "no details."
1387
1387
  });
1388
1388
  }
1389
- return this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
1389
+ const routerResponse = this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
1390
+ const sameModeFound = routerResponse.itineraries.some((itinerary) => itinerary.legs.every((leg) => leg.mode === mode));
1391
+ if (!sameModeFound) {
1392
+ return new RouterResponse({
1393
+ routerName: this.rname,
1394
+ from: waypoints[0],
1395
+ to: waypoints[1],
1396
+ error: "Selected mode of transport was not found for this itinerary."
1397
+ });
1398
+ }
1399
+ return routerResponse;
1390
1400
  }
1391
1401
  getURL(endpointUrl, mode, waypoints, options) {
1392
1402
  if (waypoints.length > 2) {