| 1 | package OpenID::Lite::Identifier; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | use overload | ||||||||||||||||||||||||||||
| 7 | 0 | ▶ | q{""} => sub { shift->as_string }, | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 8 | 5 | fallback => 1; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use URI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use OpenID::Lite::Util::URI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 20 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 20 | my $class = shift; | |||||||||||||||||||||||||||
| 15 | 20 | bless { | |||||||||||||||||||||||||||
| 16 | is_xri => 0, | ||||||||||||||||||||||||||||
| 17 | raw => '', | ||||||||||||||||||||||||||||
| 18 | }, $class; | ||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 20 | ▶ | sub normalize { | ||||||||||||||||||||||||||
|
Subroutine
normalize: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 20 | my ( $class, $uri ) = @_; | |||||||||||||||||||||||||||
| 23 | 20 | my $self = $class->new; | |||||||||||||||||||||||||||
| 24 | 20 | ▶ | if ( $uri =~ /^xri:\/\/([\=\@\+\$\!\)].+)$/ ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 25 | 1 | $self->{is_xri} = 1; | |||||||||||||||||||||||||||
| 26 | 1 | $self->{raw} = $1; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | elsif ( $uri =~ /^[\=\@\+\$\!\)]/ ) { | ||||||||||||||||||||||||||||
| 29 | 2 | $self->{is_xri} = 1; | |||||||||||||||||||||||||||
| 30 | 2 | $self->{raw} = $uri; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | else { | ||||||||||||||||||||||||||||
| 33 | 17 | $self->{is_xri} = 0; | |||||||||||||||||||||||||||
| 34 | 17 | ▶ | unless ( $uri =~ /^https?:\/\// ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 1 | $uri = sprintf q{http://%s}, $uri; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # remove fragment | ||||||||||||||||||||||||||||
| 39 | 17 | $uri =~ s/\#.*$//; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 17 | $uri = OpenID::Lite::Util::URI->normalize($uri); | |||||||||||||||||||||||||||
| 42 | 17 | ▶ | return unless OpenID::Lite::Util::URI->is_uri($uri); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 17 | my $u = URI->new($uri)->canonical; | |||||||||||||||||||||||||||
| 44 | =pod | ||||||||||||||||||||||||||||
| 45 | my $path = $u->path || '/'; | ||||||||||||||||||||||||||||
| 46 | $self->{raw} | ||||||||||||||||||||||||||||
| 47 | = ( $u->port == 80 || $u->port == 443 ) | ||||||||||||||||||||||||||||
| 48 | ? sprintf( q{%s://%s%s}, $u->scheme, $u->host, $path ) | ||||||||||||||||||||||||||||
| 49 | : sprintf( q{%s://%s:%d%s}, $u->scheme, $u->host, $u->port, | ||||||||||||||||||||||||||||
| 50 | $path ); | ||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||
| 52 | 17 | ▶ | $u->path( $u->path || '/' ); | ||||||||||||||||||||||||||
|
Condition50%1/2
$u->path || '/'
MC/DC0%0/1
$u->path || '/'
$u->path
Truth table50%1/2
A
A= $u->path
| |||||||||||||||||||||||||||||
| 53 | 17 | ▶ | $u->port( undef ) if $u->port == 80 || $u->port == 443; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$u->port == 80 or $u->port == 443
MC/DC0%0/2
$u->port == 80 or $u->port == 443
$u->port == 80
$u->port == 443
Truth table66%2/3
A or B
A= $u->port == 80B= $u->port == 443
| |||||||||||||||||||||||||||||
| 54 | 17 | $u->fragment( undef ); | |||||||||||||||||||||||||||
| 55 | 17 | $self->{raw} = $u->as_string; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 20 | return $self; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 8 | ▶ | sub is_xri { shift->{is_xri} } | ||||||||||||||||||||||||||
|
Subroutine
is_xri: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub is_http_uri { !shift->is_xri } | ||||||||||||||||||||||||||
|
Subroutine
is_http_uri: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 24 | ▶ | sub as_string { shift->{raw} } | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 5 | 1; | |||||||||||||||||||||||||||