line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Internet; |
2
|
72
|
|
|
72
|
|
4367781
|
use Mojo::Base -strict; |
|
72
|
|
|
|
|
7918
|
|
|
72
|
|
|
|
|
475
|
|
3
|
72
|
|
|
72
|
|
7169
|
use Mojolicious::Plugin::Vparam::Common; |
|
72
|
|
|
|
|
146
|
|
|
72
|
|
|
|
|
3096
|
|
4
|
|
|
|
|
|
|
|
5
|
72
|
|
|
72
|
|
970
|
use Mojo::URL; |
|
72
|
|
|
|
|
5987
|
|
|
72
|
|
|
|
|
593
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub check_email($) { |
8
|
10
|
50
|
|
10
|
0
|
23
|
return 'Value not defined' unless defined $_[0]; |
9
|
10
|
100
|
|
|
|
70
|
return 'Value is not set' unless length $_[0]; |
10
|
9
|
100
|
|
|
|
27
|
return 'Wrong format' unless Mail::RFC822::Address::valid( $_[0] ); |
11
|
7
|
|
|
|
|
1244
|
return 0; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_url($) { |
15
|
13
|
100
|
|
13
|
0
|
33
|
return 'Value not defined' unless defined $_[0]; |
16
|
12
|
100
|
|
|
|
41
|
return 'Value is not set' unless length $_[0]; |
17
|
11
|
100
|
|
|
|
2010
|
return 'Protocol not set' unless $_[0]->scheme; |
18
|
10
|
100
|
|
|
|
62
|
return 'Host not set' unless $_[0]->host; |
19
|
9
|
|
|
|
|
64
|
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
|
30
|
my ($str) = @_; |
30
|
13
|
100
|
|
|
|
32
|
return undef unless defined $str; |
31
|
12
|
|
|
|
|
43
|
return Mojo::URL->new( $str ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub register { |
35
|
74
|
|
|
74
|
0
|
1153
|
my ($class, $self, $app, $conf) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$app->vtype( |
38
|
|
|
|
|
|
|
email => |
39
|
|
|
|
|
|
|
load => 'Mail::RFC822::Address', |
40
|
10
|
|
|
10
|
|
31
|
pre => sub { trim $_[1] }, |
41
|
10
|
|
|
10
|
|
22
|
valid => sub { check_email $_[1] }, |
42
|
74
|
|
|
|
|
709
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$app->vtype( |
45
|
|
|
|
|
|
|
url => |
46
|
13
|
|
|
13
|
|
42
|
pre => sub { parse_url trim $_[1] }, |
47
|
13
|
|
|
13
|
|
33
|
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
|
|
|
61
|
? $_[1]->to_string |
52
|
|
|
|
|
|
|
: $_[1] |
53
|
|
|
|
|
|
|
; |
54
|
|
|
|
|
|
|
}, |
55
|
74
|
|
|
|
|
721
|
); |
56
|
|
|
|
|
|
|
|
57
|
74
|
|
|
|
|
277
|
return; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |