diff options
author | Daniel Friesel <derf@finalrewind.org> | 2023-02-03 18:10:59 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2023-02-03 18:10:59 +0100 |
commit | 053ae77db80d7be516b27721a84a6e6254306b62 (patch) | |
tree | 6aaba2fb056509213f66c27e79401e423a51dc51 /lib/DBInfoscreen | |
parent | bb8530ef7913c0a45939ab3837978b146ea6693e (diff) |
hafas: if there is just one candidate: redirect to it
Diffstat (limited to 'lib/DBInfoscreen')
-rw-r--r-- | lib/DBInfoscreen/Controller/Stationboard.pm | 6 |
1 files changed, 6 insertions, 0 deletions
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; |