mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-04-20 23:23:56 +03:00
determine fahrtNr by removing all non-digits
This commit is contained in:
parent
971adcdbf1
commit
73a71e0aa2
2 changed files with 18 additions and 18 deletions
|
@ -2,7 +2,7 @@ import slugg from 'slugg';
|
||||||
|
|
||||||
const parseLine = (ctx, p) => {
|
const parseLine = (ctx, p) => {
|
||||||
const profile = ctx.profile;
|
const profile = ctx.profile;
|
||||||
const fahrtNr = p.verkehrsmittel?.nummer || p.transport?.number || p.train?.no || p.no || ((p.risZuglaufId || '') + '_').split('_')[1] || p.verkehrsmittelNummer || ((p.verkehrmittel?.langText || '') + ' ').split(' ')[1] || ((p.mitteltext || '') + ' ').split(' ')[1] || ((p.zugName || '') + ' ').split(' ')[1];
|
const fahrtNr = p.verkehrsmittel?.nummer || p.transport?.number || p.train?.no || p.no || ((p.risZuglaufId || '') + '_').split('_')[1] || p.verkehrsmittelNummer || (p.verkehrmittel?.langText || p.verkehrsmittel?.langText || p.mitteltext || p.zugName || '').replace(/\D/g, '');
|
||||||
const res = {
|
const res = {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: slugg(p.verkehrsmittel?.langText || p.verkehrmittel?.langText || p.transport?.journeyDescription || p.risZuglaufId || p.train && p.train.category + ' ' + p.train.lineName + ' ' + p.train.no || p.no && p.name + ' ' + p.no || p.langtext || p.mitteltext || p.zugName), // TODO terrible
|
id: slugg(p.verkehrsmittel?.langText || p.verkehrmittel?.langText || p.transport?.journeyDescription || p.risZuglaufId || p.train && p.train.category + ' ' + p.train.lineName + ' ' + p.train.no || p.no && p.name + ' ' + p.no || p.langtext || p.mitteltext || p.zugName), // TODO terrible
|
||||||
|
|
34
test/fixtures/dbweb-departures.js
vendored
34
test/fixtures/dbweb-departures.js
vendored
|
@ -15,7 +15,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'bus',
|
id: 'bus',
|
||||||
fahrtNr: '-',
|
fahrtNr: '',
|
||||||
name: 'Bus -',
|
name: 'Bus -',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
|
@ -140,7 +140,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'bus-88x',
|
id: 'bus-88x',
|
||||||
fahrtNr: '88X',
|
fahrtNr: '88',
|
||||||
name: 'Bus 88X',
|
name: 'Bus 88X',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
|
@ -385,7 +385,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'swe26618',
|
id: 'swe26618',
|
||||||
fahrtNr: '',
|
fahrtNr: '26618',
|
||||||
name: 'SWE26618',
|
name: 'SWE26618',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'SWE',
|
productName: 'SWE',
|
||||||
|
@ -454,7 +454,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: '32673',
|
id: '32673',
|
||||||
fahrtNr: '',
|
fahrtNr: '32673',
|
||||||
name: '32673',
|
name: '32673',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'N',
|
productName: 'N',
|
||||||
|
@ -664,7 +664,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'bus',
|
id: 'bus',
|
||||||
fahrtNr: '-',
|
fahrtNr: '',
|
||||||
name: 'Bus -',
|
name: 'Bus -',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
|
@ -881,7 +881,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'swe26552',
|
id: 'swe26552',
|
||||||
fahrtNr: '',
|
fahrtNr: '26552',
|
||||||
name: 'SWE26552',
|
name: 'SWE26552',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'SWE',
|
productName: 'SWE',
|
||||||
|
@ -1205,7 +1205,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'bus-84x',
|
id: 'bus-84x',
|
||||||
fahrtNr: '84X',
|
fahrtNr: '84',
|
||||||
name: 'Bus 84X',
|
name: 'Bus 84X',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
|
@ -1457,7 +1457,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'bus',
|
id: 'bus',
|
||||||
fahrtNr: '-',
|
fahrtNr: '',
|
||||||
name: 'Bus -',
|
name: 'Bus -',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
|
@ -2232,7 +2232,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: '57775',
|
id: '57775',
|
||||||
fahrtNr: '',
|
fahrtNr: '57775',
|
||||||
name: '57775',
|
name: '57775',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'N',
|
productName: 'N',
|
||||||
|
@ -2267,7 +2267,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'swe26554',
|
id: 'swe26554',
|
||||||
fahrtNr: '',
|
fahrtNr: '26554',
|
||||||
name: 'SWE26554',
|
name: 'SWE26554',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'SWE',
|
productName: 'SWE',
|
||||||
|
@ -2442,7 +2442,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'swe26372',
|
id: 'swe26372',
|
||||||
fahrtNr: '',
|
fahrtNr: '26372',
|
||||||
name: 'SWE26372',
|
name: 'SWE26372',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'SWE',
|
productName: 'SWE',
|
||||||
|
@ -2512,7 +2512,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: '32631',
|
id: '32631',
|
||||||
fahrtNr: '',
|
fahrtNr: '32631',
|
||||||
name: '32631',
|
name: '32631',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'N',
|
productName: 'N',
|
||||||
|
@ -3071,7 +3071,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'bus-84x',
|
id: 'bus-84x',
|
||||||
fahrtNr: '84X',
|
fahrtNr: '84',
|
||||||
name: 'Bus 84X',
|
name: 'Bus 84X',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
|
@ -3176,7 +3176,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'mex19156',
|
id: 'mex19156',
|
||||||
fahrtNr: '',
|
fahrtNr: '19156',
|
||||||
name: 'MEX19156',
|
name: 'MEX19156',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'MEX',
|
productName: 'MEX',
|
||||||
|
@ -3633,7 +3633,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'bus',
|
id: 'bus',
|
||||||
fahrtNr: '-',
|
fahrtNr: '',
|
||||||
name: 'Bus -',
|
name: 'Bus -',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
|
@ -3962,7 +3962,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: '57469',
|
id: '57469',
|
||||||
fahrtNr: '',
|
fahrtNr: '57469',
|
||||||
name: '57469',
|
name: '57469',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'N',
|
productName: 'N',
|
||||||
|
@ -4207,7 +4207,7 @@ const dbwebDepartures = [
|
||||||
line: {
|
line: {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
id: 'bus-88x',
|
id: 'bus-88x',
|
||||||
fahrtNr: '88X',
|
fahrtNr: '88',
|
||||||
name: 'Bus 88X',
|
name: 'Bus 88X',
|
||||||
public: true,
|
public: true,
|
||||||
productName: 'Bus',
|
productName: 'Bus',
|
||||||
|
|
Loading…
Add table
Reference in a new issue