Skip to content

Commit 7acbe35

Browse files
author
David Emory
committed
fix(api): Add WALK to driving/TNC queries but not biking
1 parent 9c83e22 commit 7acbe35

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lib/actions/api.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if (typeof (fetch) === 'undefined') require('isomorphic-fetch')
88
import { queryIsValid } from '../util/state'
99
import queryParams from '../util/query-params'
1010
import { updateOtpUrlParams } from '../util/query'
11+
import { hasCar } from '../util/itinerary'
1112

1213
// Generic API actions
1314

@@ -123,8 +124,8 @@ function constructRoutingQuery (otpState, ignoreRealtimeUpdates) {
123124
}
124125
}
125126

126-
// hack to add walking to driving, TNC trips, bicycling
127-
if (!params.mode.includes('WALK')) {
127+
// hack to add walking to driving/TNC trips
128+
if (hasCar(params.mode)) {
128129
params.mode += ',WALK'
129130
}
130131

lib/util/itinerary.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ export function isTransit (mode) {
2121
* @return {boolean} whether any of the modes are transit modes
2222
*/
2323
export function hasTransit (modesStr) {
24-
let result = false
25-
modesStr.split(',').forEach(mode => {
26-
if (isTransit(mode)) result = true
27-
})
28-
return result
24+
modesStr.split(',').forEach(mode => { if (isTransit(mode)) return true })
25+
return false
26+
}
27+
28+
/**
29+
* @param {string} modesStr a comma-separated list of OTP modes
30+
* @return {boolean} whether any of the modes are car-based modes
31+
*/
32+
export function hasCar (modesStr) {
33+
modesStr.split(',').forEach(mode => { if (isCar(mode)) return true })
34+
return false
2935
}
3036

3137
export function isWalk (mode) {

0 commit comments

Comments
 (0)