Skip to content

Commit

Permalink
fix(RouteViewer): fix undefined error if long name missing
Browse files Browse the repository at this point in the history
  • Loading branch information
landonreed committed Dec 2, 2019
1 parent 8031b2e commit 859be14
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/components/viewers/route-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,16 @@ class RouteRow extends PureComponent {
const {defaultRouteColor, defaultRouteTextColor, longNameSplitter} = operator || {}
const color = `#${defaultRouteTextColor || route.textColor || '000000'}`
const backgroundColor = `#${defaultRouteColor || route.color || 'ffffff'}`
const nameParts = route.longName.split(longNameSplitter)
const longName = (longNameSplitter && route.longName && nameParts.length > 1)
? nameParts[1]
: route.longName
// Default long name is empty string (long name is an optional GTFS value).
let longName = ''
if (route.longName) {
// Attempt to split route name if splitter is defined for operator (to
// remove short name value from start of long name value).
const nameParts = route.longName.split(longNameSplitter)
longName = (longNameSplitter && nameParts.length > 1)
? nameParts[1]
: route.longName
}
return (
<div
style={{
Expand Down

0 comments on commit 859be14

Please sign in to comment.