| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Internet; |
|
2
|
72
|
|
|
72
|
|
4926044
|
use Mojo::Base -strict; |
|
|
72
|
|
|
|
|
11741
|
|
|
|
72
|
|
|
|
|
550
|
|
|
3
|
72
|
|
|
72
|
|
8684
|
use Mojolicious::Plugin::Vparam::Common; |
|
|
72
|
|
|
|
|
163
|
|
|
|
72
|
|
|
|
|
3623
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
72
|
|
|
72
|
|
958
|
use Mojo::URL; |
|
|
72
|
|
|
|
|
7236
|
|
|
|
72
|
|
|
|
|
679
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub check_email($) { |
|
8
|
10
|
50
|
|
10
|
0
|
26
|
return 'Value not defined' unless defined $_[0]; |
|
9
|
10
|
100
|
|
|
|
76
|
return 'Value is not set' unless length $_[0]; |
|
10
|
9
|
100
|
|
|
|
30
|
return 'Wrong format' unless Mail::RFC822::Address::valid( $_[0] ); |
|
11
|
7
|
|
|
|
|
1308
|
return 0; |
|
12
|
|
|
|
|
|
|
} |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_url($) { |
|
15
|
13
|
100
|
|
13
|
0
|
35
|
return 'Value not defined' unless defined $_[0]; |
|
16
|
12
|
100
|
|
|
|
37
|
return 'Value is not set' unless length $_[0]; |
|
17
|
11
|
100
|
|
|
|
1923
|
return 'Protocol not set' unless $_[0]->scheme; |
|
18
|
10
|
100
|
|
|
|
62
|
return 'Host not set' unless $_[0]->host; |
|
19
|
9
|
|
|
|
|
60
|
return 0; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub parse_address($) { |
|
23
|
0
|
|
|
0
|
0
|
0
|
my ($str) = @_; |
|
24
|
0
|
0
|
|
|
|
0
|
return undef unless defined $str; |
|
25
|
0
|
|
|
|
|
0
|
return Mojolicious::Plugin::Vparam::Address->parse( $str ); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub parse_url($) { |
|
29
|
13
|
|
|
13
|
0
|
26
|
my ($str) = @_; |
|
30
|
13
|
100
|
|
|
|
34
|
return undef unless defined $str; |
|
31
|
12
|
|
|
|
|
41
|
return Mojo::URL->new( $str ); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub register { |
|
35
|
74
|
|
|
74
|
0
|
1496
|
my ($class, $self, $app, $conf) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$app->vtype( |
|
38
|
|
|
|
|
|
|
email => |
|
39
|
|
|
|
|
|
|
load => 'Mail::RFC822::Address', |
|
40
|
10
|
|
|
10
|
|
35
|
pre => sub { trim $_[1] }, |
|
41
|
10
|
|
|
10
|
|
24
|
valid => sub { check_email $_[1] }, |
|
42
|
74
|
|
|
|
|
809
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$app->vtype( |
|
45
|
|
|
|
|
|
|
url => |
|
46
|
13
|
|
|
13
|
|
44
|
pre => sub { parse_url trim $_[1] }, |
|
47
|
13
|
|
|
13
|
|
31
|
valid => sub { check_url $_[1] }, |
|
48
|
|
|
|
|
|
|
post => sub { |
|
49
|
13
|
100
|
|
13
|
|
35
|
return unless defined $_[1]; |
|
50
|
|
|
|
|
|
|
return ref($_[1]) && ! $_[2]->{blessed} |
|
51
|
9
|
100
|
66
|
|
|
72
|
? $_[1]->to_string |
|
52
|
|
|
|
|
|
|
: $_[1] |
|
53
|
|
|
|
|
|
|
; |
|
54
|
|
|
|
|
|
|
}, |
|
55
|
74
|
|
|
|
|
805
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
74
|
|
|
|
|
327
|
return; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |