6 use URI::Split qw(uri_split uri_join);
8 sub j { join("-", map { defined($_) ? $_ : "<undef>" } @_) }
10 print "not " unless j(uri_split("p")) eq "<undef>-<undef>-p-<undef>-<undef>";
13 print "not " unless j(uri_split("p?q")) eq "<undef>-<undef>-p-q-<undef>";
16 print "not " unless j(uri_split("p#f")) eq "<undef>-<undef>-p-<undef>-f";
19 print "not " unless j(uri_split("p?q/#f/?")) eq "<undef>-<undef>-p-q/-f/?";
22 print "not " unless j(uri_split("s://a/p?q#f")) eq "s-a-/p-q-f";
25 print "not " unless uri_join("s", "a", "/p", "q", "f") eq "s://a/p?q#f";
28 print "not " unless uri_join("s", "a", "p", "q", "f") eq "s://a/p?q#f";
31 print "not " unless uri_join(undef, undef, "", undef, undef) eq "";
34 print "not " unless uri_join(undef, undef, "p", undef, undef) eq "p";
37 print "not " unless uri_join("s", undef, "p") eq "s:p";
40 print "not " unless uri_join("s") eq "s:";
43 print "not " unless uri_join() eq "";
46 print "not " unless uri_join("s", "a") eq "s://a";
49 print "not " unless uri_join("s", "a/b") eq "s://a%2Fb";
52 print "not " unless uri_join("s", ":/?#", ":/?#", ":/?#", ":/?#") eq "s://:%2F%3F%23/:/%3F%23?:/?%23#:/?#";
55 print "not " unless uri_join(undef, undef, "a:b") eq "a%3Ab";
58 print "not " unless uri_join("s", undef, "//foo//bar") eq "s:////foo//bar";