URI/URL.pm

filter: Statementstmt 95.8% 93 / 97 Branchbran 75.0% 21 / 28 Conditioncond 61.1% 11 / 18 MC/DCmcdc 41.6% 5 / 12 Subroutinesub 94.1% 32 / 34 Podpod 11.1% 3 / 27 totaltotal 76.3% 165 / 216 CC 22 SCAR 14.2
CC
22
Cov
87%
query
11.2
path
8.3
_init
2.0
CRAP 4.1
« URI/file/FAT.pm ↑ Summary URI/WithBase.pm »
1 package URI::URL;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use parent 'URI::WithBase';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 our $VERSION = '5.40';
9  
10 # Provide as much as possible of the old URI::URL interface for backwards
11 # compatibility...
12  
13 7 ▶use Exporter 5.57 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 7 our @EXPORT = qw(url);
15  
16 # Easy to use constructor
17 7 ▶sub url ($;$) { URI::URL->new(@_); }
Subroutine url: called CC=1 SCAR=0.0
Pod undocumented
18  
19 7 ▶use URI::Escape qw(uri_unescape);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 255 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
22 255 my $class = shift;
23 255 my $self = $class->SUPER::new(@_);
24 255 $self->[0] = $self->[0]->canonical;
25 255 $self;
26 }
27  
28 6 ▶sub newlocal {
Subroutine newlocal: called CC=1 SCAR=0.0
Pod undocumented
29 6 my $class = shift;
30 6 require URI::file;
31 6 bless [URI::file->new_abs(shift)], $class;
32 }
33  
34 {
35  
36 package URI::_foreign;
37  
38 sub _init # hope it is not defined
39 8 ▶ {
Subroutine _init: called CC=2 SCAR=7.1
40 8 my $class = shift;
41 8 ▶ die "Unknown URI::URL scheme $_[1]:" if $URI::URL::STRICT;
Branch: 1 branch
BranchTrueFalseTotal
if $URI::URL::STRICT 0 8 8
42 8 $class->SUPER::_init(@_);
43 }
44 }
45  
46 7 ▶sub strict {
Subroutine strict: called CC=2 SCAR=7.0
Pod undocumented
47 2 my $old = $URI::URL::STRICT;
48 2 ▶ $URI::URL::STRICT = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 0 2
49 2 $old;
50 }
51  
52 0 ▶sub print_on {
Subroutine print_on: not called CC=1 SCAR=6.9
Pod undocumented
53 0 my $self = shift;
54 0 require Data::Dumper;
55 0 print STDERR Data::Dumper::Dumper($self);
56 }
57  
58 42 ▶sub _try {
Subroutine _try: called CC=1 SCAR=0.0
59 42 my $self = shift;
60 42 my $method = shift;
61 42 scalar(eval { $self->$method(@_) });
62 }
63  
64 6 ▶sub crack {
Subroutine crack: called CC=1 SCAR=0.0
Pod undocumented
65  
66 # should be overridden by subclasses
67 6 my $self = shift;
68 (
69 6 scalar($self->scheme), $self->_try("user"),
70 $self->_try("password"), $self->_try("host"),
71 $self->_try("port"), $self->_try("path"),
72 $self->_try("params"), $self->_try("query"),
73 scalar($self->fragment),
74 );
75 }
76  
77 8 ▶sub full_path {
Subroutine full_path: called CC=2 SCAR=7.0
Pod undocumented
78 8 my $self = shift;
79 8 my $path = $self->path_query;
80 8 ▶ $path = "/" unless length $path;
Branch: 1 branch
BranchTrueFalseTotal
unless length $path 0 8 8
81 8 $path;
82 }
83  
84 16 ▶sub netloc {
Subroutine netloc: called CC=1 SCAR=0.0
Pod undocumented
85 16 shift->authority(@_);
86 }
87  
88 33 ▶sub epath {
Subroutine epath: called CC=1 SCAR=0.0
Pod undocumented
89 33 my $path = shift->SUPER::path(@_);
90 33 $path =~ s/;.*//;
91 33 $path;
92 }
93  
94 12 ▶sub eparams {
Subroutine eparams: called CC=2 SCAR=6.9
Pod undocumented
95 12 my $self = shift;
96 12 my @p = $self->path_segments;
97 11 ▶ return undef unless ref($p[-1]);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[-1] 8 3 11
98 3 @p = @{$p[-1]};
99 3 shift @p;
100 3 join(";", @p);
101 }
102  
103 10 ▶sub params { shift->eparams(@_); }
Subroutine params: called CC=1 SCAR=0.0
Pod undocumented
104  
105 28 ▶sub path {
Subroutine path: called CC=8 SCAR=21.2
Pod undocumented
106 28 my $self = shift;
107 28 my $old = $self->epath(@_);
108 28 ▶ return unless defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless defined wantarray 5 23 28
109 23 ▶ return '/' if !defined($old) || !length($old);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $old and length $old 0 23 23
Condition33%1/3
defined $old and length $old
!ll&&!rl&&r
0023
MC/DC0%0/2
defined $old and length $old
defined $old length $old
Truth table33%1/3
A and B
A= defined $oldB= length $old
ABresult
0X0
100
111
110 23 ▶ Carp::croak("Path components contain '/' (you must call epath)")
Branch: 1 branch
BranchTrueFalseTotal
if $old =~ /%2[fF]/ and not @_ 1 22 23
Condition66%2/3
$old =~ /%2[fF]/ and not @_
!ll&&!rl&&r
2201
MC/DC50%1/2
$old =~ /%2[fF]/ and not @_
$old =~ /%2[fF]/ not @_
Truth table66%2/3
A and not(B)
A= $old =~ /%2[fF]/B= not @_
ABresult
0X0
100
111
111 if $old =~ /%2[fF]/ and !@_;
112 22 ▶ $old = "/$old" if $old !~ m|^/| && defined $self->netloc;
Branch: 1 branch
BranchTrueFalseTotal
if not $old =~ m[^/] and defined $self->netloc 1 21 22
Condition100%3/3
not $old =~ m[^/] and defined $self->netloc
!ll&&!rl&&r
1741
MC/DC100%2/2
not $old =~ m[^/] and defined $self->netloc
not $old =~ m[^/] defined $self->netloc
Truth table100%3/3
not(A) and B
A= not $old =~ m[^/]B= defined $self->netloc
ABresult
0X0
100
111
113 22 return uri_unescape($old);
114 }
115  
116 4 ▶sub path_components {
Subroutine path_components: called CC=1 SCAR=0.0
Pod undocumented
117 4 shift->path_segments(@_);
118 }
119  
120 18 ▶sub query {
Subroutine query: called CC=10 SCAR=24.1
Pod undocumented
121 18 my $self = shift;
122 18 my $old = $self->equery(@_);
123 18 ▶ if (defined(wantarray) && defined($old)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray and defined $old) 7 11 18
Condition100%3/3
defined wantarray and defined $old
!ll&&!rl&&r
297
MC/DC100%2/2
defined wantarray and defined $old
defined wantarray defined $old
Truth table100%3/3
A and B
A= defined wantarrayB= defined $old
ABresult
0X0
100
111
124 7 ▶ if ($old =~ /%(?:26|2[bB]|3[dD])/) { # contains escaped '=' '&' or '+'
Branch: 1 branch
BranchTrueFalseTotal
if ($old =~ /%(?:26|2[bB]|3[dD])/) 1 6 7
125 1 my $mess;
126 1 for ($old) {
127 1 ▶ $mess = "Query contains both '+' and '%2B'" if /\+/ && /%2[bB]/;
Branch: 1 branch
BranchTrueFalseTotal
if /\+/ and /%2[bB]/ 0 1 1
Condition33%1/3
/\+/ and /%2[bB]/
!ll&&!rl&&r
100
MC/DC0%0/2
/\+/ and /%2[bB]/
/\+/ /%2[bB]/
Truth table33%1/3
A and B
A= /\+/B= /%2[bB]/
ABresult
0X0
100
111
128 1 ▶ $mess = "Form query contains escaped '=' or '&'"
Branch: 1 branch
BranchTrueFalseTotal
if /=/ and /%(?:3[dD]|26)/ 1 0 1
Condition33%1/3
/=/ and /%(?:3[dD]|26)/
!ll&&!rl&&r
001
MC/DC0%0/2
/=/ and /%(?:3[dD]|26)/
/=/ /%(?:3[dD]|26)/
Truth table33%1/3
A and B
A= /=/B= /%(?:3[dD]|26)/
ABresult
0X0
100
111
129 if /=/ && /%(?:3[dD]|26)/;
130 }
131 1 ▶ if ($mess) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mess) 1 0 1
132 1 Carp::croak("$mess (you must call equery)");
133 }
134 }
135  
136 # Now it should be safe to unescape the string without losing
137 # information
138 6 return uri_unescape($old);
139 }
140 11 undef;
141  
142 }
143  
144 80 ▶sub abs {
Subroutine abs: called CC=2 SCAR=6.9
Pod documented
145 80 my $self = shift;
146 80 my $base = shift;
147 80 my $allow_scheme = shift;
148 80 ▶ $allow_scheme = $URI::URL::ABS_ALLOW_RELATIVE_SCHEME
Branch: 1 branch
BranchTrueFalseTotal
unless defined $allow_scheme 60 20 80
149 unless defined $allow_scheme;
150 80 local $URI::ABS_ALLOW_RELATIVE_SCHEME = $allow_scheme;
151 80 local $URI::ABS_REMOTE_LEADING_DOTS = $URI::URL::ABS_REMOTE_LEADING_DOTS;
152 80 $self->SUPER::abs($base);
153 }
154  
155 7 ▶sub frag { shift->fragment(@_); }
Subroutine frag: called CC=1 SCAR=0.0
Pod undocumented
156 5 ▶sub keywords { shift->query_keywords(@_); }
Subroutine keywords: called CC=1 SCAR=0.0
Pod undocumented
157  
158 # file:
159 1 ▶sub local_path { shift->file; }
Subroutine local_path: called CC=1 SCAR=0.0
Pod undocumented
160 9 ▶sub unix_path { shift->file("unix"); }
Subroutine unix_path: called CC=1 SCAR=0.0
Pod undocumented
161 2 ▶sub dos_path { shift->file("dos"); }
Subroutine dos_path: called CC=1 SCAR=0.0
Pod undocumented
162 3 ▶sub mac_path { shift->file("mac"); }
Subroutine mac_path: called CC=1 SCAR=0.0
Pod undocumented
163 0 ▶sub vms_path { shift->file("vms"); }
Subroutine vms_path: not called CC=1 SCAR=6.9
Pod undocumented
164  
165 # mailto:
166 1 ▶sub address { shift->to(@_); }
Subroutine address: called CC=1 SCAR=0.0
Pod undocumented
167 1 ▶sub encoded822addr { shift->to(@_); }
Subroutine encoded822addr: called CC=1 SCAR=0.0
Pod undocumented
168 1 ▶sub URI::mailto::authority { shift->to(@_); } # make 'netloc' method work
Subroutine authority: called CC=1 SCAR=0.0
Pod documented
169  
170 # news:
171 1 ▶sub groupart { shift->_group(@_); }
Subroutine groupart: called CC=1 SCAR=0.0
Pod undocumented
172 3 ▶sub article { shift->message(@_); }
Subroutine article: called CC=1 SCAR=0.0
Pod undocumented
173  
174 7 1;
175  
176 __END__
« URI/file/FAT.pm ↑ Summary URI/WithBase.pm »