line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
6336
|
use utf8; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
15
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Interchange6::Schema::ResultSet::UriRedirect; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Interchange6::Schema::ResultSet::UriRedirect |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Provides extra accessor methods for L<Interchange6::Schema::Result::UriRedirect> |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
96
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
45
|
|
18
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
19
|
2
|
|
|
2
|
|
16
|
use mro 'c3'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
24
|
|
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
48
|
use parent 'Interchange6::Schema::ResultSet'; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
17
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 METHODS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 redirect( $source_uri ) |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Find L<Interchange6::Schema::Result::UriRedirect/uri_source> and check |
28
|
|
|
|
|
|
|
for circular redirects. In the event that a non-circular chain of redirects |
29
|
|
|
|
|
|
|
is found the last item found is returned. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Returns depend on what is found: |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over 4 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item C<$source_uri> is not found |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Returns undef. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item Circular redirect found |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns undef. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item Normal redirect found |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Returns the corresponding |
46
|
|
|
|
|
|
|
L<Interchange6::Schema::Result::UriRedirect/uri_target> and |
47
|
|
|
|
|
|
|
L<Interchange6::Schema::Result::UriRedirect/status_code> as an array |
48
|
|
|
|
|
|
|
in list context or as an array reference in scalar context. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub redirect { |
55
|
4
|
|
|
4
|
1
|
45906
|
my $self = shift; |
56
|
4
|
|
|
|
|
14
|
my $uri_source = shift; |
57
|
|
|
|
|
|
|
|
58
|
4
|
|
|
|
|
20
|
my $result = $self->find( { uri_source => $uri_source } ); |
59
|
|
|
|
|
|
|
|
60
|
4
|
100
|
|
|
|
12287
|
return undef unless defined $result; |
61
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
87
|
while ( my $next = $self->find( { uri_source => $result->uri_target } ) ) |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
# return on circular redirect |
65
|
4
|
100
|
|
|
|
12129
|
return undef if $uri_source eq $next->uri_target; |
66
|
3
|
|
|
|
|
55
|
$result = $next; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
5876
|
my @ret = ( $result->uri_target, $result->status_code ); |
70
|
|
|
|
|
|
|
|
71
|
2
|
100
|
|
|
|
96
|
return wantarray ? @ret : \@ret; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |