mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
VBB: accept station IDs with unknown length 🐛
This commit is contained in:
parent
db9287f7fd
commit
9b0e55c6ad
1 changed files with 3 additions and 4 deletions
|
@ -86,14 +86,13 @@ const parseDepartureRenameRingbahn = ({parsed}) => {
|
|||
|
||||
const validIBNR = /^\d+$/
|
||||
const formatStation = (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)) {
|
||||
if ('string' !== typeof id) throw new TypeError('station ID must be a string.')
|
||||
if (!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)
|
||||
if (id.length !== 7) id = to9Digit(id)
|
||||
return _formatStation(id)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue