1#!perl -w
2
3print "1..5\n";
4
5use URI::URL;
6
7# We used to have problems with URLs that used a base that was
8# not absolute itself.
9
10$u1 = url("/foo/bar", "http://www.acme.com/");
11$u2 = url("../foo/", $u1);
12$u3 = url("zoo/foo", $u2);
13
14$a1 = $u1->abs->as_string;
15$a2 = $u2->abs->as_string;
16$a3 = $u3->abs->as_string;
17
18print "$a1\n$a2\n$a3\n";
19
20print "not " unless $a1 eq "http://www.acme.com/foo/bar";
21print "ok 1\n";
22print "not " unless $a2 eq "http://www.acme.com/foo/";
23print "ok 2\n";
24print "not " unless $a3 eq "http://www.acme.com/foo/zoo/foo";
25print "ok 3\n";
26
27# We used to have problems with URI::URL as the base class :-(
28$u4 = url("foo", "URI::URL");
29$a4 = $u4->abs;
30print "$a4\n";
31print "not " unless $u4 eq "foo" && $a4 eq "uri:/foo";
32print "ok 4\n";
33
34# Test new_abs for URI::URL objects
35print "not " unless URI::URL->new_abs("foo", "http://foo/bar") eq "http://foo/foo";
36print "ok 5\n";
37