line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
|
|
84
|
$| = 1; |
2
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
631
|
use Test::More "no_plan"; |
|
1
|
|
|
|
|
69981
|
|
|
1
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1412
|
use URI::Pure; |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
2433
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub show_URI_for_test { |
11
|
1
|
|
|
1
|
|
3
|
my ($s) = @_; |
12
|
1
|
|
|
|
|
65
|
print "$s\n"; |
13
|
1
|
|
|
|
|
11
|
my $u = URI::Pure->new($s); |
14
|
1
|
|
|
|
|
5
|
print $u->as_string, "\n"; |
15
|
1
|
|
|
|
|
6
|
foreach (qw(scheme user password host port path query fragment)) { |
16
|
8
|
100
|
|
|
|
58
|
printf "\t%s:\t%s\n", (sprintf "%-10s", $_), $u->{$_} if defined $u->{$_}; |
17
|
|
|
|
|
|
|
} |
18
|
1
|
|
|
|
|
14
|
print "\n"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
5
|
show_URI_for_test("http://www.foo.com:80/baz/foo.html?a=b&c=d"); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
{ |
25
|
1
|
|
|
|
|
4
|
my $url = URI::Pure->new("http://www.foo.com:80/baz/foo.html?a=b&c=d"); |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
5
|
is($url->scheme, "http", "scheme"); |
28
|
1
|
|
|
|
|
478
|
is($url->user, undef, "user"); |
29
|
1
|
|
|
|
|
390
|
is($url->password, undef, "password"); |
30
|
1
|
|
|
|
|
385
|
is($url->host, "www.foo.com", "host"); |
31
|
1
|
|
|
|
|
316
|
is($url->port, "80", "port"); |
32
|
1
|
|
|
|
|
309
|
is($url->path, "/baz/foo.html", "path"); |
33
|
1
|
|
|
|
|
310
|
is($url->query, "a=b&c=d", "query"); |
34
|
1
|
|
|
|
|
305
|
is($url->fragment, undef, "fragment"); |
35
|
1
|
|
|
|
|
352
|
is($url->as_string, "http://www.foo.com/baz/foo.html?a=b&c=d", "as_string"); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
{ |
39
|
1
|
|
|
|
|
3
|
my $url = URI::Pure->new('http://u:p@www.foo.com/baz/bar.html?a=b#too'); |
|
1
|
|
|
|
|
5
|
|
40
|
1
|
|
|
|
|
5
|
is($url->scheme, "http", "scheme"); |
41
|
1
|
|
|
|
|
362
|
is($url->user, "u", "user"); |
42
|
1
|
|
|
|
|
310
|
is($url->password, "p", "password"); |
43
|
1
|
|
|
|
|
303
|
is($url->host, "www.foo.com", "host"); |
44
|
1
|
|
|
|
|
305
|
is($url->port, undef, "port"); |
45
|
1
|
|
|
|
|
343
|
is($url->path, "/baz/bar.html", "path"); |
46
|
1
|
|
|
|
|
323
|
is($url->query, "a=b", "query"); |
47
|
1
|
|
|
|
|
304
|
is($url->fragment, "too", "fragment"); |
48
|
1
|
|
|
|
|
354
|
is($url->as_string, 'http://u:p@www.foo.com/baz/bar.html?a=b#too', "as_string"); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
53
|
1
|
|
|
|
|
303
|
my $url = URI::Pure->new("urn:a:b:c:d"); |
|
1
|
|
|
|
|
7
|
|
54
|
1
|
|
|
|
|
4
|
is($url->scheme, "urn", "scheme"); |
55
|
1
|
|
|
|
|
306
|
is($url->user, undef, "user"); |
56
|
1
|
|
|
|
|
327
|
is($url->password, undef, "password"); |
57
|
1
|
|
|
|
|
348
|
is($url->host, undef, "host"); |
58
|
1
|
|
|
|
|
322
|
is($url->port, undef, "port"); |
59
|
1
|
|
|
|
|
347
|
is($url->path, "a:b:c:d", "path"); |
60
|
1
|
|
|
|
|
335
|
is($url->query, undef, "query"); |
61
|
1
|
|
|
|
|
320
|
is($url->fragment, undef, "fragment"); |
62
|
1
|
|
|
|
|
343
|
is($url->as_string, "urn:a:b:c:d", "as_string"); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
{ |
67
|
1
|
|
|
|
|
308
|
my $base = "http://a/b/c/d;p?q"; |
|
1
|
|
|
|
|
408
|
|
|
1
|
|
|
|
|
3
|
|
68
|
1
|
|
|
|
|
33
|
my @t = ( |
69
|
|
|
|
|
|
|
["http://www.baz.com/baz.html", "http://www.foo.com/baz/bar.html", "http://www.baz.com/baz.html"], |
70
|
|
|
|
|
|
|
["foo.html?a=b&c=d", "http://www.foo.com/baz/bar.html", "http://www.foo.com/baz/foo.html?a=b&c=d"], |
71
|
|
|
|
|
|
|
["foo.html?a=b&c=d", "http://www.foo.com/", "http://www.foo.com/foo.html?a=b&c=d"], |
72
|
|
|
|
|
|
|
["foo.html?a=b&c=d", "http://www.foo.com", "http://www.foo.com/foo.html?a=b&c=d"], |
73
|
|
|
|
|
|
|
["//g", $base, "http://g"], |
74
|
|
|
|
|
|
|
["g:h", $base, "g:h"], |
75
|
|
|
|
|
|
|
["g", $base, "http://a/b/c/g"], |
76
|
|
|
|
|
|
|
["./g", $base, "http://a/b/c/g"], |
77
|
|
|
|
|
|
|
["g/", $base, "http://a/b/c/g/"], |
78
|
|
|
|
|
|
|
["/g", $base, "http://a/g"], |
79
|
|
|
|
|
|
|
["//g", $base, "http://g"], |
80
|
|
|
|
|
|
|
["?y", $base, "http://a/b/c/d;p?y"], |
81
|
|
|
|
|
|
|
["g?y", $base, "http://a/b/c/g?y"], |
82
|
|
|
|
|
|
|
["#s", $base, "http://a/b/c/d;p?q#s"], |
83
|
|
|
|
|
|
|
["g#s", $base, "http://a/b/c/g#s"], |
84
|
|
|
|
|
|
|
["g?y#s", $base, "http://a/b/c/g?y#s"], |
85
|
|
|
|
|
|
|
[";x", $base, "http://a/b/c/;x"], |
86
|
|
|
|
|
|
|
["g;x", $base, "http://a/b/c/g;x"], |
87
|
|
|
|
|
|
|
["g;x?y#s", $base, "http://a/b/c/g;x?y#s"], |
88
|
|
|
|
|
|
|
["", $base, "http://a/b/c/d;p?q"], |
89
|
|
|
|
|
|
|
[".", $base, "http://a/b/c/"], |
90
|
|
|
|
|
|
|
["./", $base, "http://a/b/c/"], |
91
|
|
|
|
|
|
|
["..", $base, "http://a/b/"], |
92
|
|
|
|
|
|
|
["../", $base, "http://a/b/"], |
93
|
|
|
|
|
|
|
["../g", $base, "http://a/b/g"], |
94
|
|
|
|
|
|
|
["../..", $base, "http://a/"], |
95
|
|
|
|
|
|
|
["../../", $base, "http://a/"], |
96
|
|
|
|
|
|
|
["../../g", $base, "http://a/g"], |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
11
|
print "\nTests for abs:\n"; |
100
|
1
|
|
|
|
|
5
|
my $i = 0; |
101
|
1
|
|
|
|
|
3
|
foreach (@t) { |
102
|
28
|
|
|
|
|
8461
|
my ($url, $base, $expected) = @$_; |
103
|
28
|
|
|
|
|
85
|
my $u = URI::Pure->new($url); |
104
|
28
|
|
|
|
|
53
|
my $b = URI::Pure->new($base); |
105
|
28
|
|
|
|
|
61
|
my $got = $u->abs($b)->as_string; |
106
|
28
|
|
|
|
|
44
|
$i++; |
107
|
28
|
|
|
|
|
84
|
is($got, $expected, "abs $i"); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
326
|
print "\nTests for normalization:\n"; |
113
|
|
|
|
|
|
|
{ |
114
|
1
|
|
|
|
|
3
|
my @t = ( |
|
1
|
|
|
|
|
18
|
|
115
|
|
|
|
|
|
|
["/", "/"], |
116
|
|
|
|
|
|
|
[".", "."], |
117
|
|
|
|
|
|
|
["//", ""], # Тут - host, а не path |
118
|
|
|
|
|
|
|
["//a", ""], # Тут a - это host, а не path |
119
|
|
|
|
|
|
|
["/a/", "/a/"], |
120
|
|
|
|
|
|
|
["/a/b/.", "/a/b/"], |
121
|
|
|
|
|
|
|
["/a//b/./c/d", "/a/b/c/d"], |
122
|
|
|
|
|
|
|
["a//b/./c/d", "a/b/c/d"], |
123
|
|
|
|
|
|
|
["/a/b/../d", "/a/d"], |
124
|
|
|
|
|
|
|
["/a/../c/d", "/c/d"], |
125
|
|
|
|
|
|
|
["/a/b/../../c", "/c"], |
126
|
|
|
|
|
|
|
["/a/../../b", "/b"], |
127
|
|
|
|
|
|
|
["a/../../b", "../b"], |
128
|
|
|
|
|
|
|
["a/../../../b", "../../b"], |
129
|
|
|
|
|
|
|
["/b/c/..", "/b/"], |
130
|
|
|
|
|
|
|
["a1/a2/a3/a4/a5/../../b", "a1/a2/a3/b"], |
131
|
|
|
|
|
|
|
["a1/a2/a3/a4/a5/../../../b", "a1/a2/b"], |
132
|
|
|
|
|
|
|
["a1/a2/a3/a4/a5/../../../../b", "a1/b"], |
133
|
|
|
|
|
|
|
["a1/a2/a3/a4/a5/../../../../../b", "b"], |
134
|
|
|
|
|
|
|
["a1/a2/a3/a4/a5/../../../../../../b", "../b"], |
135
|
|
|
|
|
|
|
); |
136
|
|
|
|
|
|
|
|
137
|
1
|
|
|
|
|
2
|
my $i = 0; |
138
|
1
|
|
|
|
|
4
|
foreach (@t) { |
139
|
20
|
|
|
|
|
6194
|
my ($u, $e) = @$_; |
140
|
20
|
|
|
|
|
29
|
$i++; |
141
|
20
|
|
|
|
|
59
|
is (URI::Pure->new($u)->path, $e, "normalize $i"); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
1
|
|
|
|
|
320
|
print "\nInternationalized Resource Identifier\n"; |
148
|
|
|
|
|
|
|
{ |
149
|
1
|
|
|
|
|
4
|
my $u = URI::Pure->new("http://Інтернаціоналізовані.Доменні.Імена/Головна/сторінка?a=Вітаю&b=До побачення"); |
|
1
|
|
|
|
|
6
|
|
150
|
1
|
|
|
|
|
4
|
my $e = "http://xn--80aaahmo1ambbffeu2a2e1ohef.xn--d1acufac6o.xn--80ajuf6j/%D0%93%D0%BE%D0%BB%D0%BE%D0%B2%D0%BD%D0%B0/%D1%81%D1%82%D0%BE%D1%80%D1%96%D0%BD%D0%BA%D0%B0?a=%D0%92%D1%96%D1%82%D0%B0%D1%8E&b=%D0%94%D0%BE%20%D0%BF%D0%BE%D0%B1%D0%B0%D1%87%D0%B5%D0%BD%D0%BD%D1%8F"; |
151
|
1
|
|
|
|
|
6
|
is ($u->as_string, $e, "IDN"); |
152
|
1
|
|
|
|
|
425
|
is ($u->as_iri, "http://інтернаціоналізовані.доменні.імена/Головна/сторінка?a=Вітаю&b=До побачення", "IRI"); |
153
|
|
|
|
|
|
|
} |