From 7ea79b6f44ba106be459accce88627b1e1f00501 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Fri, 3 Feb 2023 12:41:49 +0100 Subject: [PATCH] Don't crash if segments.geom is null. Somtimes (for example https://www.sac-cas.ch/it/capanne-e-escursioni/portale-escursionistico-del-cas/albristhubel-6246/escursioni-con-le-racchette/von-matten-simmental-2785/) segments.geom is null and the creation of the gpx xml subsequently fails. If that is the case just ignore it and do not try to turn it into a track segment. Thanks to wizche for the report and fix! --- README.md | 3 +++ background.js | 5 +++-- manifest.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 537ddfa..5e58206 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,6 @@ Heed their warning and do not blindly follow the gps track! Use your brain and plan your route beforehand to be aware of dangerous parts and alternatives. Take a look at their [safety instructions](https://www.sac-cas.ch/en/training-and-safety/safety/). + +## Contributors +- wizche diff --git a/background.js b/background.js index 7afc979..95ccd76 100644 --- a/background.js +++ b/background.js @@ -89,9 +89,10 @@ function trackTitle(geoJson) { */ function toGpx(geoJson) { let trackSegments = geoJson.segments.map((segment) => { + if (segment.geom == null) return ""; return ` - ${segment.geom.coordinates.map(toTrackPoint).join("")} - `; + ${segment.geom.coordinates.map(toTrackPoint).join("")} + `; }).join(""); let endPoint = geoJson.end_point ? toWayPoint(geoJson.end_point) : ""; diff --git a/manifest.json b/manifest.json index 60ddb60..b738a29 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "SAC Route Portal GPX Downloader", - "version": "0.6", + "version": "0.7", "developer": { "name": "Sebastian Hugentobler", "url": "https://code.vanwa.ch/sebastian/sac-route-portal-gpx-fx"