From 053ae77db80d7be516b27721a84a6e6254306b62 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 3 Feb 2023 18:10:59 +0100 Subject: hafas: if there is just one candidate: redirect to it --- lib/DBInfoscreen/Controller/Stationboard.pm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/DBInfoscreen') diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 1077dce..bf986d3 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -46,6 +46,12 @@ sub handle_no_results { sub { my (@candidates) = @_; @candidates = map { [ $_->{name}, $_->{id} ] } @candidates; + if ( @candidates == 1 ) { + my $s = $candidates[0][0]; + my $params = $self->req->params->to_string; + $self->redirect_to("/${s}?${params}"); + return; + } for my $candidate (@candidates) { $candidate->[0] =~ s{[&]#x0028;}{(}g; $candidate->[0] =~ s{[&]#x0029;}{)}g; -- cgit v1.2.3