mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
VBB: support 7-digit stations
This commit is contained in:
parent
b0157c75d5
commit
595c745830
2 changed files with 11 additions and 6 deletions
|
@ -128,10 +128,16 @@ const createParseDeparture = (profile, stations, lines, remarks) => {
|
|||
return parseDepartureRenameRingbahn
|
||||
}
|
||||
|
||||
const isIBNR = /^\d{9,}$/
|
||||
const validIBNR = /^\d+$/
|
||||
const formatStation = (id) => {
|
||||
if (!isIBNR.test(id)) throw new Error('station ID must be an IBNR.')
|
||||
id = to9Digit(id)
|
||||
if ('string' !== typeof id) throw new Error('station ID must be a string.')
|
||||
const l = id.length
|
||||
if ((l !== 7 && l !== 9 && l !== 12) || !validIBNR.test(id)) {
|
||||
throw new Error('station ID must be a valid IBNR.')
|
||||
}
|
||||
// The VBB has some 7-digit stations. We don't convert them to 12 digits,
|
||||
// because it only recognizes in the 7-digit format. see derhuerst/vbb-hafas#22
|
||||
if (l !== 7) id = to9Digit(id)
|
||||
return _formatStation(id)
|
||||
}
|
||||
|
||||
|
|
|
@ -260,10 +260,9 @@ test('departures', co.wrap(function* (t) {
|
|||
t.end()
|
||||
}))
|
||||
|
||||
// todo
|
||||
test.skip('departures at 7-digit station', co.wrap(function* (t) {
|
||||
test('departures at 7-digit station', co.wrap(function* (t) {
|
||||
const eisenach = '8010097' // see derhuerst/vbb-hafas#22
|
||||
yield client.departures(eisenach, {when})
|
||||
await client.departures(eisenach, {when})
|
||||
t.pass('did not fail')
|
||||
|
||||
t.end()
|
||||
|
|
Loading…
Add table
Reference in a new issue