Link/Redirect.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran n/a Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 39 CC 1 SCAR 6.9
CC
1
Cov
0%
implement_redirect
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 =head1 NAME
2  
3 WWW::Link::Redirect - redirect analysis
4  
5 =head1 DESCRIPTION
6  
7 Redirects are used for lots of reasons. Most of them bad. When doing
8 link checking, we want to ignore those redirects which are done for
9 bad reasons and only focus on those which are really telling us that
10 something has been reorganised.
11  
12 The standards tell us that we can look at the difference between a
13 permanent redirect and a temporary one. Unfortunately nobody reads
14 standards.
15  
16 We use some heuristics to help us make our own assesment.
17  
18 =head1 FUNCTION
19  
20 =cut
21  
22 =head2 implementation redirect
23  
24 sometimes an artefact of software implementation means that a web page
25 may be referenced on one page but read on another. This is a very bad
26 thing from their point of view, but means that we don't want to change
27 anything on our pages.
28  
29 Example
30  
31 http://example.com/
32  
33 http://example.com/our_web_designers/start-here.active_summit_page
34  
35 or
36  
37 http://example.com/
38  
39 http://web4.example.com/first.html.txt.zip.active.exe
40  
41 our heuristic is that if the end of the authority is maintained and
42 the start of the path is maintained then we consider this mistake
43 simply a design mistake.
44  
45 =cut
46  
47 use URI;
48 use Carp;
49  
50 sub implement_redirect {
51 my $original=URI->new(shift);
52 my $final=URI->new(shift);
53 ref $original and ref $final or
54 die "usage implement_redirect(orig_uri, final_uri)";
55 URI::eq($original, $final) and return 1;
56 $final->scheme() eq $original->scheme() or return 0;
57 #FIXME non common URIs???
58  
59 $origauth=$original->authority();
60 $origpath=$original->path();
61 $final->authority =~ m/\Q$origauth\E$/ or return 0;
62 $final->path =~ m/^\Q$origpath\E/ or return 0;
63 #ignore fragment... who cares!
64 return 1;
65 }