line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Format::Validate::URL; |
2
|
|
|
|
|
|
|
our $VERSION = q/0.2/; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
147296
|
use Carp; |
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
104
|
|
5
|
2
|
|
|
2
|
|
10
|
use base q/Exporter/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
652
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ |
8
|
|
|
|
|
|
|
looks_like_any_url |
9
|
|
|
|
|
|
|
looks_like_full_url |
10
|
|
|
|
|
|
|
/; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
13
|
|
|
|
|
|
|
q/all/ => [qw/ |
14
|
|
|
|
|
|
|
looks_like_any_url |
15
|
|
|
|
|
|
|
looks_like_full_url |
16
|
|
|
|
|
|
|
/] |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub looks_like_any_url ($) { |
20
|
|
|
|
|
|
|
|
21
|
11
|
|
33
|
11
|
0
|
133
|
$_ = shift || croak q/Value must be provided/; |
22
|
11
|
|
|
|
|
92
|
/^ |
23
|
|
|
|
|
|
|
((https?|ftp):\/\/)? |
24
|
|
|
|
|
|
|
[a-z0-9-]+(\.[a-z0-9-]+)+ |
25
|
|
|
|
|
|
|
([\/?].*)? |
26
|
|
|
|
|
|
|
$/ix |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub looks_like_full_url ($) { |
30
|
|
|
|
|
|
|
|
31
|
8
|
|
33
|
8
|
0
|
101
|
$_ = shift || croak q/Value must be provided/; |
32
|
8
|
|
|
|
|
48
|
/^ |
33
|
|
|
|
|
|
|
(https?|ftp):\/\/ |
34
|
|
|
|
|
|
|
(www|ftp)\. |
35
|
|
|
|
|
|
|
[a-z0-9-]+(\.[a-z0-9-]+)+ |
36
|
|
|
|
|
|
|
([\/?].*)? |
37
|
|
|
|
|
|
|
$/ix |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=pod |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=encoding utf8 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Data::Format::Validate::URL - A URL validating module. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SYNOPSIS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Module that validate URL. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 Utilities |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item Any URL |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use Data::Format::Validate::URL 'looks_like_any_url'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
looks_like_any_url 'duckduckgo.com'; # 1 |
62
|
|
|
|
|
|
|
looks_like_any_url 'www.duckduckgo.com'; # 1 |
63
|
|
|
|
|
|
|
looks_like_any_url 'ftp.duckduckgo.com'; # 1 |
64
|
|
|
|
|
|
|
looks_like_any_url 'http://duckduckgo.com'; # 1 |
65
|
|
|
|
|
|
|
looks_like_any_url 'ftp://www.duckduckgo.com'; # 1 |
66
|
|
|
|
|
|
|
looks_like_any_url 'https://www.duckduckgo.com'; # 1 |
67
|
|
|
|
|
|
|
looks_like_any_url 'https://www.youtube.com/watch?v=tqgBN44orKs'; # 1 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
looks_like_any_url '.com'; # 0 |
70
|
|
|
|
|
|
|
looks_like_any_url 'www. duckduckgo'; # 0 |
71
|
|
|
|
|
|
|
looks_like_any_url 'this is not an url'; # 0 |
72
|
|
|
|
|
|
|
looks_like_any_url 'perl.com is the best website'; # 0 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item Only full URL |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
use Data::Format::Validate::URL 'looks_like_full_url'; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
looks_like_full_url 'ftp://www.duckduckgo.com'; # 1 |
79
|
|
|
|
|
|
|
looks_like_full_url 'http://www.duckduckgo.com'; # 1 |
80
|
|
|
|
|
|
|
looks_like_full_url 'https://www.duckduckgo.com'; # 1 |
81
|
|
|
|
|
|
|
looks_like_full_url 'http://www.duckduckgo.com/search?q=perl'; # 1 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
looks_like_full_url 'duckduckgo.com'; # 0 |
84
|
|
|
|
|
|
|
looks_like_full_url 'www.duckduckgo.com'; # 0 |
85
|
|
|
|
|
|
|
looks_like_full_url 'ftp.duckduckgo.com'; # 0 |
86
|
|
|
|
|
|
|
looks_like_full_url 'http://duckduckgo.com'; # 0 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 CONTRIBUITION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This source is on Github: |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
https://github.com/rozcovo/Data-Format-Validate/blob/master/lib/Data/Format/Validate/URL.pm |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Created by Israel Batista <> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |