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.
This commit is contained in:
Henrik Fehlauer 2023-07-08 09:50:13 +00:00
parent 96016b7fd0
commit 8809fa94cf
No known key found for this signature in database
GPG key ID: 177EECC0FF03B880

View file

@ -179,7 +179,7 @@
class GpsiesVoiceHints extends WaypointVoiceHints { class GpsiesVoiceHints extends WaypointVoiceHints {
_getWpt(hint, cmd, coord) { _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 };
} }
} }