diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-11-04 18:49:09 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-11-04 18:49:09 +0100 |
commit | ce21810e88853a12823902cdf7e7291f1516c376 (patch) | |
tree | 3a2fcf691086d3d2d4683fff61085112438842c1 /index.pl | |
parent | 37aba10e6fd760f48bc03bb3a7bfbcdb8a45832d (diff) |
(sort of) support station names containing slashes
Diffstat (limited to 'index.pl')
-rw-r--r-- | index.pl | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -306,7 +306,7 @@ helper 'json_route_diff' => sub { sub handle_request { my $self = shift; my $station = $self->stash('station'); - my $via = $self->stash('via'); + my $via = $self->stash('via') // $self->param('via'); my @platforms = split( /,/, $self->param('platforms') // q{} ); my @lines = split( /,/, $self->param('lines') // q{} ); @@ -365,6 +365,18 @@ sub handle_request { return; } + # foo/bar used to mean "departures for foo via bar", and this is still the + # default. However, there are also stations named "foo/bar". So, if + # "foo" is not a valid station, try "foo/bar" instead + if ( not @results and $self->stash('via')) { + $station = "$station/$via"; + $via = undef; + $data = get_results_for( $backend, $station, %opt ); + $results_ref = $data->{results}; + $errstr = $data->{errstr}; + @results = @{$results_ref}; + } + if ( not @results ) { $self->handle_no_results( $backend, $station, $errstr ); return; @@ -847,13 +859,11 @@ sub handle_request { get '/_redirect' => sub { my $self = shift; my $station = $self->param('station'); - my $via = $self->param('via'); my $params = $self->req->params; $params->remove('station'); - $params->remove('via'); - for my $param (qw(platforms backend mode admode)) { + for my $param (qw(platforms backend mode admode via)) { if ( not $params->param($param) or ( exists $default{$param} @@ -866,12 +876,7 @@ get '/_redirect' => sub { $params = $params->to_string; - if ($via) { - $self->redirect_to("/${station}/${via}?${params}"); - } - else { - $self->redirect_to("/${station}?${params}"); - } + $self->redirect_to("/${station}?${params}"); }; get '/_auto' => sub { |