@wemap/routers 11.8.4 → 11.8.6

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.js CHANGED
@@ -344,7 +344,7 @@ class Itinerary {
344
344
  isDriving = isDriving || leg.mode === "CAR";
345
345
  });
346
346
  if (isPublicTransport) {
347
- this._mode = "PT";
347
+ this._mode = "MULTI";
348
348
  } else if (isDriving) {
349
349
  this._mode = "CAR";
350
350
  } else if (isBicycle) {
@@ -1388,7 +1388,17 @@ class IdfmRemoteRouter extends RemoteRouter {
1388
1388
  error: jsonResponse.error.message || "no details."
1389
1389
  });
1390
1390
  }
1391
- return this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
1391
+ const routerResponse = this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
1392
+ const sameModeFound = routerResponse.itineraries.some((itinerary) => itinerary.mode === mode);
1393
+ if (!sameModeFound) {
1394
+ return new RouterResponse({
1395
+ routerName: this.rname,
1396
+ from: waypoints[0],
1397
+ to: waypoints[1],
1398
+ error: "Selected mode of transport was not found for this itinerary."
1399
+ });
1400
+ }
1401
+ return routerResponse;
1392
1402
  }
1393
1403
  getURL(endpointUrl, mode, waypoints, options) {
1394
1404
  if (waypoints.length > 2) {