From 9b0e55c6ad08945963ab1f3e2baf7ea0a97b66b3 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 31 Jan 2020 19:54:13 +0100 Subject: [PATCH] VBB: accept station IDs with unknown length :bug: --- p/vbb/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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) }