1
0

Clean train name string before parsing

This commit is contained in:
clerie 2020-09-16 14:16:47 +02:00
parent a4c68ec801
commit 0c17dfc94f

View File

@ -17,7 +17,7 @@ function getMediaURL(path) {
* they will also be cleaned up and returned as undefined, because we can't link to them correctly * they will also be cleaned up and returned as undefined, because we can't link to them correctly
*/ */
function bahnParseTrainName(dirty_train_name) { function bahnParseTrainName(dirty_train_name) {
var name_list = dirty_train_name.split(" "); var name_list = dirty_train_name.trim().replace(/ +/g, ' ').split(" ");
// Train name in format "STB 12 (23561)" // Train name in format "STB 12 (23561)"
if(name_list.length == 3 && name_list[2].charAt(0) == '(' && name_list[2].charAt(name_list[2].length-1) == ')') { if(name_list.length == 3 && name_list[2].charAt(0) == '(' && name_list[2].charAt(name_list[2].length-1) == ')') {