1 package URI::file::Base;
10 $path = "" unless defined $path;
12 my($auth, $escaped_auth, $escaped_path);
14 ($auth, $escaped_auth) = $class->_file_extract_authority($path);
15 ($path, $escaped_path) = $class->_file_extract_path($path);
18 $auth =~ s,%,%25,g unless $escaped_auth;
19 $auth =~ s,([/?\#]),$URI::Escape::escapes{$1},g;
22 $path = "/$path" unless substr($path, 0, 1) eq "/";
27 return undef unless defined $path;
31 $path =~ s,([%;?]),$URI::Escape::escapes{$1},g unless $escaped_path;
34 my $uri = $auth . $path;
35 $uri = "file:$uri" if substr($uri, 0, 1) eq "/";
37 URI->new($uri, "file");
40 sub _file_extract_authority
42 my($class, $path) = @_;
43 return undef unless $class->_file_is_absolute($path);
44 return $URI::file::DEFAULT_AUTHORITY;
47 sub _file_extract_path
57 sub _file_is_localhost
61 return 1 if $host eq "localhost";
64 lc(Net::Domain::hostfqdn()) eq $host ||
65 lc(Net::Domain::hostname()) eq $host;