allow letting hafas decide the amount of vias

This commit is contained in:
dabund24 2025-02-05 19:47:48 +01:00
parent bb480cdb6a
commit 239c279573
2 changed files with 6 additions and 1 deletions

View file

@ -11,7 +11,7 @@ const formatStationBoardReq = (ctx, station, type) => {
zeit: profile.formatTimeOfDay(profile, opt.when),
datum: profile.formatDate(profile, opt.when),
mitVias: maxVias !== 0 ? true : undefined,
maxVias,
maxVias: maxVias === -1 ? undefined : maxVias,
verkehrsmittel: profile.formatProductsFilter(ctx, opt.products || {}),
},
method: 'GET',

View file

@ -62,6 +62,11 @@ tap.test('formats an arrivals() request with different vias option', (t) => {
t.equal(reqViasNull.query.mitVias, undefined);
t.equal(reqViasNull.query.maxVias, 0);
ctx.opt.vias = -1;
const reqViasUnlimited = profile.formatStationBoardReq(ctx, '8011160', 'arrivals');
t.equal(reqViasUnlimited.query.mitVias, true);
t.equal(reqViasUnlimited.query.maxVias, undefined);
ctx.opt.vias = 42;
const reqViasFourtyTwo = profile.formatStationBoardReq(ctx, '8011160', 'arrivals');
t.equal(reqViasFourtyTwo.query.mitVias, true);