mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 01:56:33 +02: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 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 = {
 | 
			
		||||
		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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										34
									
								
								test/fixtures/dbweb-departures.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										34
									
								
								test/fixtures/dbweb-departures.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -15,7 +15,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'bus',
 | 
			
		||||
			fahrtNr: '-',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			name: 'Bus -',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'Bus',
 | 
			
		||||
| 
						 | 
				
			
			@ -140,7 +140,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'bus-88x',
 | 
			
		||||
			fahrtNr: '88X',
 | 
			
		||||
			fahrtNr: '88',
 | 
			
		||||
			name: 'Bus 88X',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'Bus',
 | 
			
		||||
| 
						 | 
				
			
			@ -385,7 +385,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'swe26618',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			fahrtNr: '26618',
 | 
			
		||||
			name: 'SWE26618',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'SWE',
 | 
			
		||||
| 
						 | 
				
			
			@ -454,7 +454,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: '32673',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			fahrtNr: '32673',
 | 
			
		||||
			name: '32673',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'N',
 | 
			
		||||
| 
						 | 
				
			
			@ -664,7 +664,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'bus',
 | 
			
		||||
			fahrtNr: '-',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			name: 'Bus -',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'Bus',
 | 
			
		||||
| 
						 | 
				
			
			@ -881,7 +881,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'swe26552',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			fahrtNr: '26552',
 | 
			
		||||
			name: 'SWE26552',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'SWE',
 | 
			
		||||
| 
						 | 
				
			
			@ -1205,7 +1205,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'bus-84x',
 | 
			
		||||
			fahrtNr: '84X',
 | 
			
		||||
			fahrtNr: '84',
 | 
			
		||||
			name: 'Bus 84X',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'Bus',
 | 
			
		||||
| 
						 | 
				
			
			@ -1457,7 +1457,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'bus',
 | 
			
		||||
			fahrtNr: '-',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			name: 'Bus -',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'Bus',
 | 
			
		||||
| 
						 | 
				
			
			@ -2232,7 +2232,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: '57775',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			fahrtNr: '57775',
 | 
			
		||||
			name: '57775',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'N',
 | 
			
		||||
| 
						 | 
				
			
			@ -2267,7 +2267,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'swe26554',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			fahrtNr: '26554',
 | 
			
		||||
			name: 'SWE26554',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'SWE',
 | 
			
		||||
| 
						 | 
				
			
			@ -2442,7 +2442,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'swe26372',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			fahrtNr: '26372',
 | 
			
		||||
			name: 'SWE26372',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'SWE',
 | 
			
		||||
| 
						 | 
				
			
			@ -2512,7 +2512,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: '32631',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			fahrtNr: '32631',
 | 
			
		||||
			name: '32631',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'N',
 | 
			
		||||
| 
						 | 
				
			
			@ -3071,7 +3071,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'bus-84x',
 | 
			
		||||
			fahrtNr: '84X',
 | 
			
		||||
			fahrtNr: '84',
 | 
			
		||||
			name: 'Bus 84X',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'Bus',
 | 
			
		||||
| 
						 | 
				
			
			@ -3176,7 +3176,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'mex19156',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			fahrtNr: '19156',
 | 
			
		||||
			name: 'MEX19156',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'MEX',
 | 
			
		||||
| 
						 | 
				
			
			@ -3633,7 +3633,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'bus',
 | 
			
		||||
			fahrtNr: '-',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			name: 'Bus -',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'Bus',
 | 
			
		||||
| 
						 | 
				
			
			@ -3962,7 +3962,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: '57469',
 | 
			
		||||
			fahrtNr: '',
 | 
			
		||||
			fahrtNr: '57469',
 | 
			
		||||
			name: '57469',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'N',
 | 
			
		||||
| 
						 | 
				
			
			@ -4207,7 +4207,7 @@ const dbwebDepartures = [
 | 
			
		|||
		line: {
 | 
			
		||||
			type: 'line',
 | 
			
		||||
			id: 'bus-88x',
 | 
			
		||||
			fahrtNr: '88X',
 | 
			
		||||
			fahrtNr: '88',
 | 
			
		||||
			name: 'Bus 88X',
 | 
			
		||||
			public: true,
 | 
			
		||||
			productName: 'Bus',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue