From bb32333ee20326e9125ff2de0c9c7bbd22ee8bb4 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 21 Mar 2021 10:53:04 +0100 Subject: landing page: accept both train numbers and station names --- lib/DBInfoscreen/Controller/Static.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lib/DBInfoscreen/Controller') diff --git a/lib/DBInfoscreen/Controller/Static.pm b/lib/DBInfoscreen/Controller/Static.pm index 4a645ed..c25c6c5 100644 --- a/lib/DBInfoscreen/Controller/Static.pm +++ b/lib/DBInfoscreen/Controller/Static.pm @@ -1,4 +1,5 @@ package DBInfoscreen::Controller::Static; + # Copyright (C) 2011-2020 Daniel Friesel # # SPDX-License-Identifier: AGPL-3.0-or-later @@ -11,11 +12,11 @@ my %default = ( ); sub redirect { - my ($self) = @_; - my $station = $self->param('station'); - my $params = $self->req->params; + my ($self) = @_; + my $input = $self->param('input'); + my $params = $self->req->params; - $params->remove('station'); + $params->remove('input'); for my $param (qw(platforms mode admode via)) { if ( @@ -30,7 +31,12 @@ sub redirect { $params = $params->to_string; - $self->redirect_to("/${station}?${params}"); + if ( $input =~ m{ ^ [a-zA-Z]{1,5} \s+ \d+ $ }x ) { + $self->redirect_to("/z/${input}?${params}"); + } + else { + $self->redirect_to("/${input}?${params}"); + } } sub geolocation { -- cgit v1.2.3