Blossom/_URL.pm

filter: Statementstmt 100% 42 / 42 Branchbran 90.0% 27 / 30 Conditioncond 75.7% 25 / 33 MC/DCmcdc 55.5% 10 / 18 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 83.9% 110 / 131 CC 27 SCAR 26.3
CC
27
Cov
90%
_http_url
19.0
_valid_http_authority
10.0
BEGIN
1.0
CRAP 13.9
« Blossom/URI.pm ↑ Summary Blossom/Error.pm »
1 package Net::Blossom::_URL;
2  
3 5 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use URI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 51 ▶sub http_base_url {
Subroutine http_base_url: called CC=1 SCAR=0.0
Pod undocumented
8 51 my ($value) = @_;
9 51 return _http_url($value, allow_path => 1);
10 }
11  
12 7 ▶sub http_root_url {
Subroutine http_root_url: called CC=1 SCAR=0.0
Pod undocumented
13 7 my ($value) = @_;
14 7 return _http_url($value, allow_path => 0);
15 }
16  
17 58 ▶sub _http_url {
Subroutine _http_url: called CC=18 SCAR=29.4
18 58 my ($value, %opts) = @_;
19 58 ▶ return 0 unless defined $value && !ref($value) && length $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and length $value 1 57 58
Condition66%4/6
defined $value and not ref $value and length $value
!ll&&!rl&&r
1057
defined $value and not ref $value
!ll&&!rl&&r
0157
MC/DC33%1/3
defined $value and not ref $value and length $value
defined $value not ref $value length $value
Truth table50%2/4
A and not(B) and C
A= defined $valueB= not ref $valueC= length $value
ABCresult
0XX0
10X0
1100
1111
20 57 ▶ return 0 if $value =~ /[\x00-\x20]/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /[\x00-\x20]/ 1 56 57
21  
22 56 my $uri = URI->new($value);
23 56 my $scheme = $uri->scheme;
24 56 ▶ return 0 unless defined $scheme && $scheme =~ /\Ahttps?\z/i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scheme and $scheme =~ /\Ahttps?\z/i 2 54 56
Condition100%3/3
defined $scheme and $scheme =~ /\Ahttps?\z/i
!ll&&!rl&&r
1154
MC/DC100%2/2
defined $scheme and $scheme =~ /\Ahttps?\z/i
defined $scheme $scheme =~ /\Ahttps?\z/i
Truth table100%3/3
A and B
A= defined $schemeB= $scheme =~ /\Ahttps?\z/i
ABresult
0X0
100
111
25  
26 54 my $authority = eval { $uri->authority };
27 54 ▶ return 0 unless _valid_http_authority($authority);
Branch: 1 branch
BranchTrueFalseTotal
unless _valid_http_authority($authority) 6 48 54
28  
29 48 my $host = eval { $uri->host };
30 48 ▶ return 0 unless defined $host && length $host;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $host and length $host 0 48 48
Condition33%1/3
defined $host and length $host
!ll&&!rl&&r
0048
MC/DC0%0/2
defined $host and length $host
defined $host length $host
Truth table33%1/3
A and B
A= defined $hostB= length $host
ABresult
0X0
100
111
31  
32 48 my $userinfo = eval { $uri->userinfo };
33 48 ▶ return 0 if defined $userinfo && length $userinfo;
Branch: 1 branch
BranchTrueFalseTotal
if defined $userinfo and length $userinfo 0 48 48
Condition33%1/3
defined $userinfo and length $userinfo
!ll&&!rl&&r
4800
MC/DC0%0/2
defined $userinfo and length $userinfo
defined $userinfo length $userinfo
Truth table33%1/3
A and B
A= defined $userinfoB= length $userinfo
ABresult
0X0
100
111
34 48 ▶ return 0 if defined $uri->query;
Branch: 1 branch
BranchTrueFalseTotal
if defined $uri->query 2 46 48
35 46 ▶ return 0 if defined $uri->fragment;
Branch: 1 branch
BranchTrueFalseTotal
if defined $uri->fragment 1 45 46
36  
37 45 my $path = $uri->path;
38 45 ▶ return 0 if !$opts{allow_path} && defined($path) && length($path) && $path ne '/';
Branch: 1 branch
BranchTrueFalseTotal
if not $opts{"allow_path"} and defined $path and length $path and $path ne "/" 2 43 45
Condition88%8/9
not $opts{"allow_path"} and defined $path and length $path and $path ne "/"
!ll&&!rl&&r
4212
not $opts{"allow_path"} and defined $path and length $path
!ll&&!rl&&r
3933
not $opts{"allow_path"} and defined $path
!ll&&!rl&&r
3906
MC/DC75%3/4
not $opts{"allow_path"} and defined $path and length $path and $path ne "/"
not $opts{"allow_path"} defined $path length $path $path ne "/"
Truth table80%4/5
not(A) and B and C and D
A= not $opts{"allow_path"}B= defined $pathC= length $pathD= $path ne "/"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
39  
40 43 return 1;
41 }
42  
43 54 ▶sub _valid_http_authority {
Subroutine _valid_http_authority: called CC=10 SCAR=23.1
44 54 my ($authority) = @_;
45 54 ▶ return 0 unless defined $authority && length $authority;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $authority and length $authority 1 53 54
Condition66%2/3
defined $authority and length $authority
!ll&&!rl&&r
0153
MC/DC50%1/2
defined $authority and length $authority
defined $authority length $authority
Truth table66%2/3
A and B
A= defined $authorityB= length $authority
ABresult
0X0
100
111
46 53 ▶ return 0 if $authority =~ /\@/;
Branch: 1 branch
BranchTrueFalseTotal
if $authority =~ /\@/ 1 52 53
47  
48 52 my $port;
49 52 ▶ if ($authority =~ /\A\[[0-9A-Fa-f:.]+\](?::([0-9]+))?\z/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($authority =~ /\A\[[0-9A-Fa-f:.]+\](?::([0-9]+))?\z/) { } 1 51 52
elsif ($authority =~ /\A([^:]+)(?::([0-9]+))?\z/) { } 49 2 51
50 1 $port = $1;
51 }
52 elsif ($authority =~ /\A([^:]+)(?::([0-9]+))?\z/) {
53 49 ▶ return 0 if $1 =~ /[\[\]]/;
Branch: 1 branch
BranchTrueFalseTotal
if $1 =~ /[\[\]]/ 0 49 49
54 49 $port = $2;
55 }
56 else {
57 2 return 0;
58 }
59  
60 50 ▶ return 0 if defined $port && ($port < 1 || $port > 65535);
Branch: 1 branch
BranchTrueFalseTotal
if defined $port and $port < 1 || $port > 65535 2 48 50
Condition100%6/6
defined $port and $port < 1 || $port > 65535
!ll&&!rl&&r
4622
$port < 1 or $port > 65535
l!l&&r!l&&!r
112
MC/DC100%3/3
defined $port and $port < 1 || $port > 65535
defined $port $port < 1 $port > 65535
Truth table100%4/4
A and B or C
A= defined $portB= $port < 1C= $port > 65535
ABCresult
0XX0
1000
11X1
1011
61 48 return 1;
62 }
63  
64 5 1;
« Blossom/URI.pm ↑ Summary Blossom/Error.pm »