| 1 | package Protocol::WebSocket::URL; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 212 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 7 | 212 | my $class = shift; | |||||||||||||||||||||||||||
| 8 | 212 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 212 | my $self = {@_}; | |||||||||||||||||||||||||||
| 11 | 212 | bless $self, $class; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 212 | ▶ | $self->{secure} ||= 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"secure"} ||= 0
MC/DC100%1/1
$self->{"secure"} ||= 0
$self->{"secure"}
Truth table100%2/2
A
A= $self->{"secure"}
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 212 | return $self; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 255 | ▶ | sub secure { @_ > 1 ? $_[0]->{secure} = $_[1] : $_[0]->{secure} } | ||||||||||||||||||||||||||
|
Subroutine
secure: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 285 | ▶ | sub host { @_ > 1 ? $_[0]->{host} = $_[1] : $_[0]->{host} } | ||||||||||||||||||||||||||
|
Subroutine
host: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 260 | ▶ | sub port { @_ > 1 ? $_[0]->{port} = $_[1] : $_[0]->{port} } | ||||||||||||||||||||||||||
|
Subroutine
port: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 243 | ▶ | sub resource_name { | ||||||||||||||||||||||||||
|
Subroutine
resource_name: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 243 | ▶ | @_ > 1 ? $_[0]->{resource_name} = $_[1] : $_[0]->{resource_name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 31 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=9 SCAR=22.5
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 31 | my $self = shift; | |||||||||||||||||||||||||||
| 29 | 31 | my $string = shift; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 31 | my ($scheme) = $string =~ m{^(wss?)://}; | |||||||||||||||||||||||||||
| 32 | 31 | ▶ | return unless $scheme; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 31 | ▶ | $self->secure(1) if $scheme =~ m/ss$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 31 | my ($host, $port) = $string =~ m{^$scheme://([^:\/]+)(?::(\d+))?(?:|\/|$)}; | |||||||||||||||||||||||||||
| 37 | 31 | ▶ | $host = '/' unless defined $host && $host ne ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $host and $host ne ""
MC/DC0%0/2
defined $host and $host ne ""
defined $host
$host ne ""
Truth table33%1/3
A and B
A= defined $hostB= $host ne ""
| |||||||||||||||||||||||||||||
| 38 | 31 | $self->host($host); | |||||||||||||||||||||||||||
| 39 | 31 | ▶ | $port ||= $self->secure ? 443 : 80; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$port ||= $self->secure ? 443 : 80
MC/DC0%0/2
$port ||= $self->secure ? 443 : 80
$port
$self->secure ? 443 : 80
Truth table66%2/3
A ||= B
A= $portB= $self->secure ? 443 : 80
| |||||||||||||||||||||||||||||
| 40 | 31 | $self->port($port); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # path and query | ||||||||||||||||||||||||||||
| 43 | 31 | my ($pnq) = $string =~ m{^$scheme://(?:.*?)(/.*)$}; | |||||||||||||||||||||||||||
| 44 | 31 | ▶ | $pnq = '/' unless defined $pnq && $pnq ne ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $pnq and $pnq ne ""
MC/DC50%1/2
defined $pnq and $pnq ne ""
defined $pnq
$pnq ne ""
Truth table66%2/3
A and B
A= defined $pnqB= $pnq ne ""
| |||||||||||||||||||||||||||||
| 45 | 31 | $self->resource_name($pnq); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 31 | return $self; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 181 | ▶ | sub to_string { | ||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | 181 | my $self = shift; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 181 | my $string = ''; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 181 | $string .= 'ws'; | |||||||||||||||||||||||||||
| 56 | 181 | ▶ | $string .= 's' if $self->secure; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 181 | $string .= '://'; | |||||||||||||||||||||||||||
| 58 | 181 | $string .= $self->host; | |||||||||||||||||||||||||||
| 59 | 181 | ▶ | $string .= ':' . $self->port if defined $self->port; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 181 | ▶ | $string .= $self->resource_name || '/'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->resource_name || '/'
MC/DC100%1/1
$self->resource_name || '/'
$self->resource_name
Truth table100%2/2
A
A= $self->resource_name
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 181 | return $string; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 15 | 1; | |||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||