10 use URI::Heuristic qw(uf_urlstr uf_url);
12 $URI::Heuristic::DEBUG++;
13 open(STDERR, ">&STDOUT"); # redirect STDERR
16 print "not " unless uf_urlstr("http://www.sn.no/") eq "http://www.sn.no/";
20 print "not " unless uf_urlstr("etc:passwd") eq "file:/etc/passwd";
22 print "not " unless uf_urlstr("/etc/passwd") eq "file:/etc/passwd";
27 print "not " unless uf_urlstr(":foo.txt") eq "file:./foo.txt";
29 print "not " unless uf_urlstr("./foo.txt") eq "file:./foo.txt";
33 print "not " unless uf_urlstr("ftp.aas.no/lwp.tar.gz") eq "ftp://ftp.aas.no/lwp.tar.gz";
37 # its a weird, but valid, MacOS path, so it can't be left alone
38 print "not " unless uf_urlstr("C:\\CONFIG.SYS") eq "file:/C/%5CCONFIG.SYS";
40 print "not " unless uf_urlstr("C:\\CONFIG.SYS") eq "file:C:\\CONFIG.SYS";
44 if (gethostbyname("www.netscape.com")) {
45 # DNS probably work, lets run test 6..8
47 $URI::Heuristic::MY_COUNTRY = "bv";
48 print "not " unless uf_urlstr("perl/camel.gif") eq "http://www.perl.com/camel.gif";
51 $URI::Heuristic::MY_COUNTRY = "uk";
52 print "not " unless uf_urlstr("perl/camel.gif") =~ m,^http://www\.perl\.(org|co)\.uk/camel\.gif$,;
55 $ENV{URL_GUESS_PATTERN} = "www.ACME.org www.ACME.com";
56 print "not " unless uf_urlstr("perl") eq "http://www.perl.org";
60 # don't make the inocent worry
61 print "Skipping test 6-8 because DNS does not work\n";
62 for (6..8) { print "ok $_\n"; }
67 local $ENV{URL_GUESS_PATTERN} = "";
68 print "not " unless uf_urlstr("perl") eq "http://perl";
71 print "not " unless uf_urlstr("http:80") eq "http:80";
74 print "not " unless uf_urlstr("mailto:gisle\@aas.no") eq "mailto:gisle\@aas.no";
77 print "not " unless uf_urlstr("gisle\@aas.no") eq "mailto:gisle\@aas.no";
80 print "not " unless uf_urlstr("Gisle.Aas\@aas.perl.org") eq "mailto:Gisle.Aas\@aas.perl.org";
83 print "not " unless uf_url("gopher.sn.no")->scheme eq "gopher";
86 print "not " unless uf_urlstr("123.3.3.3:8080/foo") eq "http://123.3.3.3:8080/foo";
91 #print "not " unless uf_urlstr("some-site") eq "http://www.some-site.com";
94 #print "not " unless uf_urlstr("some-site.com") eq "http://some-site.com";