From 8809fa94cf11fa011271a531fb9842b035210b7e Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Sat, 8 Jul 2023 09:50:13 +0000 Subject: [PATCH] Prevent Gpsies-style export from throwing for undefined symbols While abrensch/brouter@82fecf9 fixed the export already by avoiding the problematic `OFFR` voice hint, we would still throw in case we encountered an `undefined` symbol entry: > Uncaught TypeError: Cannot read properties of undefined (reading > 'toLowerCase') This can be prevented by not calling `toLowerCase()` on `undefined` objects. Fixes #751 Test Plan: - Change `VoiceHints.commands` to contain `undefined` entries for a particular voice hint. - Create a route with that voice hint. - Test that exporting for each `turnInstructionMode` does not throw. --- js/format/VoiceHints.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/format/VoiceHints.js b/js/format/VoiceHints.js index 0910af2..bcc748d 100644 --- a/js/format/VoiceHints.js +++ b/js/format/VoiceHints.js @@ -179,7 +179,7 @@ class GpsiesVoiceHints extends WaypointVoiceHints { _getWpt(hint, cmd, coord) { - return { name: cmd.message, sym: cmd.symbol.toLowerCase(), type: cmd.symbol }; + return { name: cmd.message, sym: cmd.symbol?.toLowerCase(), type: cmd.symbol }; } }