| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
5
|
|
|
5
|
|
1405990
|
use strict; |
|
|
5
|
|
|
|
|
34
|
|
|
|
5
|
|
|
|
|
167
|
|
|
2
|
5
|
|
|
5
|
|
30
|
use warnings FATAL => 'all'; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
379
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package MarpaX::ESLIF::URI; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: URI as per RFC3986/RFC6874 |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:JDDPAUSE'; # AUTHORITY |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.007'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
36
|
use Carp qw/croak/; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
350
|
|
|
13
|
5
|
|
|
5
|
|
2376
|
use Class::Load qw/load_class/; |
|
|
5
|
|
|
|
|
79482
|
|
|
|
5
|
|
|
|
|
355
|
|
|
14
|
5
|
|
|
5
|
|
2814
|
use MarpaX::ESLIF::URI::_generic; |
|
|
5
|
|
|
|
|
21
|
|
|
|
5
|
|
|
|
|
1424
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $re_scheme = qr/[A-Za-z][A-Za-z0-9+\-.]*/; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
|
20
|
32
|
|
|
32
|
1
|
21266
|
my ($class, $str, $scheme) = @_; |
|
21
|
|
|
|
|
|
|
|
|
22
|
32
|
50
|
|
|
|
136
|
croak '$str must be defined' unless defined($str); |
|
23
|
|
|
|
|
|
|
|
|
24
|
32
|
|
|
|
|
68
|
my $self; |
|
25
|
32
|
|
|
|
|
82
|
$str = "$str"; |
|
26
|
32
|
50
|
0
|
|
|
466
|
if ($str =~ /^($re_scheme):/o) { |
|
|
|
0
|
|
|
|
|
|
|
27
|
32
|
|
|
|
|
117
|
$scheme = $1 |
|
28
|
|
|
|
|
|
|
} elsif (defined($scheme) && ($scheme =~ /^$re_scheme$/o)) { |
|
29
|
0
|
|
|
|
|
0
|
$str = "$scheme:$str" |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
32
|
50
|
|
|
|
123
|
if (defined($scheme)) { |
|
33
|
|
|
|
|
|
|
# |
|
34
|
|
|
|
|
|
|
# If defined, $scheme is guaranteed to contain only ASCII characters |
|
35
|
|
|
|
|
|
|
# |
|
36
|
32
|
|
|
|
|
96
|
my $lc_scheme = lc($scheme); |
|
37
|
32
|
|
|
|
|
63
|
$self = eval { load_class("MarpaX::ESLIF::URI::$lc_scheme")->new($str) } |
|
|
32
|
|
|
|
|
216
|
|
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
# |
|
40
|
|
|
|
|
|
|
# Fallback to _generic |
|
41
|
|
|
|
|
|
|
# |
|
42
|
32
|
|
33
|
|
|
434
|
$self //= MarpaX::ESLIF::URI::_generic->new($str) |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding UTF-8 |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
MarpaX::ESLIF::URI - URI as per RFC3986/RFC6874 |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 VERSION |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
version 0.007 |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
use feature 'say'; |
|
65
|
|
|
|
|
|
|
use Data::Dumper; |
|
66
|
|
|
|
|
|
|
use MarpaX::ESLIF::URI; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $http_url = "http://[2001:db8:a0b:12f0::1%25Eth0]:80/index.html"; |
|
69
|
|
|
|
|
|
|
my $http_uri = MarpaX::ESLIF::URI->new($http_url); |
|
70
|
|
|
|
|
|
|
say $http_uri->scheme; # http |
|
71
|
|
|
|
|
|
|
say $http_uri->host; # [2001:db8:a0b:12f0::1%Eth0] |
|
72
|
|
|
|
|
|
|
say $http_uri->hostname; # 2001:db8:a0b:12f0::1%Eth0 |
|
73
|
|
|
|
|
|
|
say $http_uri->path; # /index.html |
|
74
|
|
|
|
|
|
|
say $http_uri->ip; # 2001:db8:a0b:12f0::1%Eth0 |
|
75
|
|
|
|
|
|
|
say $http_uri->ipv6; # 2001:db8:a0b:12f0::1 |
|
76
|
|
|
|
|
|
|
say $http_uri->zone; # Eth0 |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $file_url = "file:/c|/path/to/file"; |
|
79
|
|
|
|
|
|
|
my $file_uri = MarpaX::ESLIF::URI->new($file_url); |
|
80
|
|
|
|
|
|
|
say $file_uri->scheme; # file |
|
81
|
|
|
|
|
|
|
say $file_uri->string; # file:/c|/path/to/file |
|
82
|
|
|
|
|
|
|
say $file_uri->drive; # c |
|
83
|
|
|
|
|
|
|
say $file_uri->path; # /c|/path/to/file |
|
84
|
|
|
|
|
|
|
say Dumper($file_uri->segments); # [ 'c|', 'path', 'to', 'file' ] |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $mail_url = "mailto:bogus\@email.com,bogus2\@email.com?" |
|
87
|
|
|
|
|
|
|
. "subject=test%20subject&" |
|
88
|
|
|
|
|
|
|
. "body=This%20is%20the%20body%20of%20this%20message."; |
|
89
|
|
|
|
|
|
|
my $mail_uri = MarpaX::ESLIF::URI->new($mail_url); |
|
90
|
|
|
|
|
|
|
say $mail_uri->scheme; # mailto |
|
91
|
|
|
|
|
|
|
say Dumper($mail_uri->to); # bogus\@email.com, bogus2\@email.com |
|
92
|
|
|
|
|
|
|
say Dumper($mail_uri->headers); # { 'subject' => 'test subject', 'body' => 'This is the body of this message.' } |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 $class->new($str, $scheme) |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns a instance that is a MarpaX::ESLIF::URI::$scheme representation of C<$str>, when C<$scheme> defaults to C<_generic> if there is no specific C<$scheme> implementation, or if the later fails. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
All methods of L<MarpaX::ESLIF::URI::_generic> are available, sometimes extended or modified by specific scheme implementations. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 NOTES |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Percent-encoded characters are decoded to ASCII characters corresponding to every percent-encoded byte. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<MarpaX::ESLIF::URI::_generic>, L<MarpaX::ESLIF::URI::file>, L<MarpaX::ESLIF::URI::ftp>, L<MarpaX::ESLIF::URI::http>, L<MarpaX::ESLIF::URI::https>, L<MarpaX::ESLIF::URI::mailto>, L<MarpaX::ESLIF::URI::tag>, L<MarpaX::ESLIF::URI::tel>. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Jean-Damien Durand <jeandamiendurand@free.fr> |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=for stopwords Jean-Damien Durand |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Jean-Damien Durand <Jean-Damien.Durand@newaccess.ch> |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Jean-Damien Durand. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
125
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |