From e6f7a095050d0d7e913698432e8d9222f08b74f6 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 12 Dec 2017 23:40:12 +0100 Subject: [PATCH] more fixes for 3811b45 :bug: --- format/address.js | 4 ++-- format/location.js | 6 +++--- format/poi.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/format/address.js b/format/address.js index 01f90b11..2774c380 100644 --- a/format/address.js +++ b/format/address.js @@ -3,13 +3,13 @@ const formatCoord = require('./coord') const formatAddress = (a) => { - if (!a.type !== 'location' || !a.latitude || !a.longitude || !a.address) { + if (a.type !== 'location' || !a.latitude || !a.longitude || !a.address) { throw new Error('invalid address') } return { type: 'A', - name: a.name, + name: a.address, crd: { x: formatCoord(a.longitude), y: formatCoord(a.latitude) diff --git a/format/location.js b/format/location.js index 3401e32e..121cd13f 100644 --- a/format/location.js +++ b/format/location.js @@ -2,10 +2,10 @@ const formatLocation = (profile, l) => { if ('string' === typeof l) return profile.formatStation(l) - if ('object' === typeof l) { + if ('object' === typeof l && !Array.isArray(l)) { if (l.type === 'station') return profile.formatStation(l.id) - if (l.type === 'poi') return profile.formatPoi(l) - if (l.type === 'address') return profile.formatAddress(l) + if ('string' === typeof l.id) return profile.formatPoi(l) + if ('string' === typeof l.address) return profile.formatAddress(l) throw new Error('invalid location type: ' + l.type) } throw new Error('valid station, address or poi required.') diff --git a/format/poi.js b/format/poi.js index bb2d137d..3991e4c6 100644 --- a/format/poi.js +++ b/format/poi.js @@ -3,7 +3,7 @@ const formatCoord = require('./coord') const formatPoi = (p) => { - if (!p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) { + if (p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) { throw new Error('invalid POI') }