aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Response.pm
blob: 16ebf995f85a52ac6cc5209687dc5e0a31d831c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# This package exists to try and work around a big bug in Edge:
# https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8572187/

package FixMyStreet::App::Response;
use Moose;
extends 'Catalyst::Response';

around 'redirect' => sub {
    my $orig = shift;
    my $self = shift;
    my ($location, $status) = @_;

    return $self->$orig() unless @_;  # getter

    my $agent = $self->_context->request->user_agent;
    return $self->$orig(@_) unless $agent =~ /Edge\/14/;  # Only care about Edge

    # Instead of a redirect, output HTML that redirects
    $self->body(<<END
<meta http-equiv="refresh" content="0; url=$location">
Please follow this link: <a href="$location">$location</a>
END
    );
    return $location;
};

1;