diff --git a/p/vbb/index.js b/p/vbb/index.js index c3adbf4c..e426ff23 100644 --- a/p/vbb/index.js +++ b/p/vbb/index.js @@ -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) }