line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cikl::DataTypes::Url; |
2
|
3
|
|
|
3
|
|
22890
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
110
|
|
3
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
89
|
|
4
|
3
|
|
|
3
|
|
936
|
use namespace::autoclean; |
|
3
|
|
|
|
|
101311
|
|
|
3
|
|
|
|
|
25
|
|
5
|
3
|
|
|
3
|
|
456
|
use Mouse::Util::TypeConstraints; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
33
|
|
6
|
3
|
|
|
3
|
|
2055
|
use URI; |
|
3
|
|
|
|
|
18258
|
|
|
3
|
|
|
|
|
218
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
29
|
use constant RE_URL_SCHEME => qr/^[-+.a-zA-Z0-9]+:\/\//; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2240
|
|
9
|
|
|
|
|
|
|
our @ALLOWED_SCHEMES = qw( |
10
|
|
|
|
|
|
|
http |
11
|
|
|
|
|
|
|
https |
12
|
|
|
|
|
|
|
ftp |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $RESTR_ALLOWED_SCHEMES = join('|', @ALLOWED_SCHEMES); |
16
|
|
|
|
|
|
|
our $RE_ALLOWED_SCHEMES = qr/^($RESTR_ALLOWED_SCHEMES)$/; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# We want an absolute URL |
19
|
|
|
|
|
|
|
subtype 'Cikl::DataTypes::Url', |
20
|
|
|
|
|
|
|
as 'Str', |
21
|
|
|
|
|
|
|
where { |
22
|
|
|
|
|
|
|
my $url_text = shift; |
23
|
|
|
|
|
|
|
my $url = URI->new($url_text); |
24
|
|
|
|
|
|
|
return ( |
25
|
|
|
|
|
|
|
defined($url->scheme) # must have a scheme |
26
|
|
|
|
|
|
|
&& ($url->scheme() =~ $RE_ALLOWED_SCHEMES) |
27
|
|
|
|
|
|
|
&& $url->can('host') # must have a host component |
28
|
|
|
|
|
|
|
&& $url->can('port') # must respond to port |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
message { "Invalid URL '" . ($_ || '(undef)') . "'"} ; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|