ctucx.git: trainsearch

web based trip-planner, fork of https://cyberchaos.dev/yuka/trainsearch

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
export const Request = globalThis.Request;

export const fetch = (resource, options) => {
	if (!(resource instanceof Request)) {
		resource = new Request(resource);
	}


	const replacement = {
		'https://app.vendo.noncd.db.de/mob/location/search':       '/db/vendo/locations',
		'https://app.vendo.noncd.db.de/mob/angebote/fahrplan':     '/db/vendo/journeys',
		'https://app.vendo.noncd.db.de/mob/angebote/recon':        '/db/vendo/journey',
		'https://app.vendo.noncd.db.de/mob/bahnhofstafel/abfahrt': '/db/vendo/departures',
		'https://nah.sh.hafas.de/bin/mgate.exe?':                  '/hafas/nahsh',
		'https://www.rmv.de/auskunft/bin/jp/mgate.exe?':           '/hafas/rmv',
		'https://vrn.hafas.de/bin/mgate.exe?':                     '/hafas/vrn',
		'https://bvg-apps-ext.hafas.de/bin/mgate.exe?':            '/hafas/bvg',
		'https://fahrplan.oebb.at/bin/mgate.exe?':                 '/hafas/oebb',
	};

	let url = replacement[resource.url];

	if (url === undefined) {
		url = resource.url.replace('https://app.vendo.noncd.db.de/mob/location/details', '/db/vendo/location');
		url = url.replace('https://app.vendo.noncd.db.de/mob/zuglauf',                   '/db/vendo/trip');
	}

	resource = new Request(url, resource);
	return globalThis.fetch(resource, options);
}