| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Internet; |
|
2
|
73
|
|
|
73
|
|
2177958
|
use Mojo::Base -strict; |
|
|
73
|
|
|
|
|
128729
|
|
|
|
73
|
|
|
|
|
413
|
|
|
3
|
73
|
|
|
73
|
|
7758
|
use Mojolicious::Plugin::Vparam::Common; |
|
|
73
|
|
|
|
|
130
|
|
|
|
73
|
|
|
|
|
3355
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
73
|
|
|
73
|
|
730
|
use Mojo::URL; |
|
|
73
|
|
|
|
|
5524
|
|
|
|
73
|
|
|
|
|
596
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub check_email($) { |
|
8
|
10
|
50
|
|
10
|
0
|
23
|
return 'Value not defined' unless defined $_[0]; |
|
9
|
10
|
100
|
|
|
|
25
|
return 'Value is not set' unless length $_[0]; |
|
10
|
9
|
100
|
|
|
|
20
|
return 'Wrong format' unless Mail::RFC822::Address::valid( $_[0] ); |
|
11
|
7
|
|
|
|
|
1120
|
return 0; |
|
12
|
|
|
|
|
|
|
} |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_url($) { |
|
15
|
13
|
100
|
|
13
|
0
|
29
|
return 'Value not defined' unless defined $_[0]; |
|
16
|
12
|
100
|
|
|
|
35
|
return 'Value is not set' unless length $_[0]; |
|
17
|
11
|
100
|
|
|
|
2246
|
return 'Protocol not set' unless $_[0]->scheme; |
|
18
|
10
|
100
|
|
|
|
49
|
return 'Host not set' unless $_[0]->host; |
|
19
|
9
|
|
|
|
|
49
|
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
|
24
|
my ($str) = @_; |
|
30
|
13
|
100
|
|
|
|
30
|
return undef unless defined $str; |
|
31
|
12
|
|
|
|
|
34
|
return Mojo::URL->new( $str ); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub register { |
|
35
|
75
|
|
|
75
|
0
|
226
|
my ($class, $self, $app, $conf) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$app->vtype( |
|
38
|
|
|
|
|
|
|
email => |
|
39
|
|
|
|
|
|
|
load => 'Mail::RFC822::Address', |
|
40
|
10
|
|
|
10
|
|
25
|
pre => sub { trim $_[1] }, |
|
41
|
10
|
|
|
10
|
|
16
|
valid => sub { check_email $_[1] }, |
|
42
|
75
|
|
|
|
|
752
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$app->vtype( |
|
45
|
|
|
|
|
|
|
url => |
|
46
|
13
|
|
|
13
|
|
30
|
pre => sub { parse_url trim $_[1] }, |
|
47
|
13
|
|
|
13
|
|
28
|
valid => sub { check_url $_[1] }, |
|
48
|
|
|
|
|
|
|
post => sub { |
|
49
|
13
|
100
|
|
13
|
|
28
|
return unless defined $_[1]; |
|
50
|
|
|
|
|
|
|
return ref($_[1]) && ! $_[2]->{blessed} |
|
51
|
9
|
100
|
66
|
|
|
47
|
? $_[1]->to_string |
|
52
|
|
|
|
|
|
|
: $_[1] |
|
53
|
|
|
|
|
|
|
; |
|
54
|
|
|
|
|
|
|
}, |
|
55
|
75
|
|
|
|
|
807
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
75
|
|
|
|
|
327
|
return; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |