handle stop objects as input 🐛, 3.8.1

This commit is contained in:
Jannis R 2019-02-06 22:24:00 +01:00
parent b84db19efb
commit 3f58d84de5
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 9 additions and 3 deletions

View file

@ -3,7 +3,9 @@
const formatLocation = (profile, l, name = 'location') => {
if ('string' === typeof l) return profile.formatStation(l)
if ('object' === typeof l && !Array.isArray(l)) {
if (l.type === 'station') return profile.formatStation(l.id)
if (l.type === 'station' || l.type === 'stop') {
return profile.formatStation(l.id)
}
if ('string' === typeof l.id) return profile.formatPoi(l)
if ('string' === typeof l.address) return profile.formatAddress(l)
if (!l.type) throw new Error(`missing ${name}.type`)

View file

@ -1,7 +1,7 @@
{
"name": "hafas-client",
"description": "Client for HAFAS public transport APIs.",
"version": "3.8.0",
"version": "3.8.1",
"main": "index.js",
"files": [
"index.js",

View file

@ -50,7 +50,11 @@ const wedding = '900000009104'
const württembergallee = '900000026153'
test('journeys  Spichernstr. to Bismarckstr.', co(function* (t) {
const journeys = yield client.journeys(spichernstr, bismarckstr, {
const journeys = yield client.journeys({
type: 'stop',
id: spichernstr,
name: 'U Spichernstr.'
}, bismarckstr, {
results: 3,
departure: when,
stopovers: true