Skip to content

Commit

Permalink
Prevent Gpsies-style export from throwing for undefined symbols
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rkflx committed Jul 8, 2023
1 parent 96016b7 commit 8809fa9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/format/VoiceHints.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
}

Expand Down

0 comments on commit 8809fa9

Please sign in to comment.