<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package URI::URL;

require URI::WithBase;
@ISA=qw(URI::WithBase);

use strict;
use vars qw(@EXPORT $VERSION);

$VERSION = "5.04";

# Provide as much as possible of the old URI::URL interface for backwards
# compatibility...

require Exporter;
*import = \&amp;Exporter::import;
@EXPORT = qw(url);

# Easy to use constructor
sub url ($;$) { URI::URL-&gt;new(@_); }

use URI::Escape qw(uri_unescape);

sub new
{
    my $class = shift;
    my $self = $class-&gt;SUPER::new(@_);
    $self-&gt;[0] = $self-&gt;[0]-&gt;canonical;
    $self;
}

sub newlocal
{
    my $class = shift;
    require URI::file;
    bless [URI::file-&gt;new_abs(shift)], $class;
}

{package URI::_foreign;
    sub _init  # hope it is not defined
    {
	my $class = shift;
	die "Unknown URI::URL scheme $_[1]:" if $URI::URL::STRICT;
	$class-&gt;SUPER::_init(@_);
    }
}

sub strict
{
    my $old = $URI::URL::STRICT;
    $URI::URL::STRICT = shift if @_;
    $old;
}

sub print_on
{
    my $self = shift;
    require Data::Dumper;
    print STDERR Data::Dumper::Dumper($self);
}

sub _try
{
    my $self = shift;
    my $method = shift;
    scalar(eval { $self-&gt;$method(@_) });
}

sub crack
{
    # should be overridden by subclasses
    my $self = shift;
    (scalar($self-&gt;scheme),
     $self-&gt;_try("user"),
     $self-&gt;_try("password"),
     $self-&gt;_try("host"),
     $self-&gt;_try("port"),
     $self-&gt;_try("path"),
     $self-&gt;_try("params"),
     $self-&gt;_try("query"),
     scalar($self-&gt;fragment),
    )
}

sub full_path
{
    my $self = shift;
    my $path = $self-&gt;path_query;
    $path = "/" unless length $path;
    $path;
}

sub netloc
{
    shift-&gt;authority(@_);
}

sub epath
{
    my $path = shift-&gt;SUPER::path(@_);
    $path =~ s/;.*//;
    $path;
}

sub eparams
{
    my $self = shift;
    my @p = $self-&gt;path_segments;
    return unless ref($p[-1]);
    @p = @{$p[-1]};
    shift @p;
    join(";", @p);
}

sub params { shift-&gt;eparams(@_); }

sub path {
    my $self = shift;
    my $old = $self-&gt;epath(@_);
    return unless defined wantarray;
    return '/' if !defined($old) || !length($old);
    Carp::croak("Path components contain '/' (you must call epath)")
	if $old =~ /%2[fF]/ and !@_;
    $old = "/$old" if $old !~ m|^/| &amp;&amp; defined $self-&gt;netloc;
    return uri_unescape($old);
}

sub path_components {
    shift-&gt;path_segments(@_);
}

sub query {
    my $self = shift;
    my $old = $self-&gt;equery(@_);
    if (defined(wantarray) &amp;&amp; defined($old)) {
	if ($old =~ /%(?:26|2[bB]|3[dD])/) {  # contains escaped '=' '&amp;' or '+'
	    my $mess;
	    for ($old) {
		$mess = "Query contains both '+' and '%2B'"
		  if /\+/ &amp;&amp; /%2[bB]/;
		$mess = "Form query contains escaped '=' or '&amp;'"
		  if /=/  &amp;&amp; /%(?:3[dD]|26)/;
	    }
	    if ($mess) {
		Carp::croak("$mess (you must call equery)");
	    }
	}
	# Now it should be safe to unescape the string without loosing
	# information
	return uri_unescape($old);
    }
    undef;

}

sub abs
{
    my $self = shift;
    my $base = shift;
    my $allow_scheme = shift;
    $allow_scheme = $URI::URL::ABS_ALLOW_RELATIVE_SCHEME
	unless defined $allow_scheme;
    local $URI::ABS_ALLOW_RELATIVE_SCHEME = $allow_scheme;
    local $URI::ABS_REMOTE_LEADING_DOTS = $URI::URL::ABS_REMOTE_LEADING_DOTS;
    $self-&gt;SUPER::abs($base);
}

sub frag { shift-&gt;fragment(@_); }
sub keywords { shift-&gt;query_keywords(@_); }

# file:
sub local_path { shift-&gt;file; }
sub unix_path  { shift-&gt;file("unix"); }
sub dos_path   { shift-&gt;file("dos");  }
sub mac_path   { shift-&gt;file("mac");  }
sub vms_path   { shift-&gt;file("vms");  }

# mailto:
sub address { shift-&gt;to(@_); }
sub encoded822addr { shift-&gt;to(@_); }
sub URI::mailto::authority { shift-&gt;to(@_); }  # make 'netloc' method work

# news:
sub groupart { shift-&gt;_group(@_); }
sub article  { shift-&gt;message(@_); }

1;

__END__

=head1 NAME

URI::URL - Uniform Resource Locators

=head1 SYNOPSIS

 $u1 = URI::URL-&gt;new($str, $base);
 $u2 = $u1-&gt;abs;

=head1 DESCRIPTION

This module is provided for backwards compatibility with modules that
depend on the interface provided by the C&lt;URI::URL&gt; class that used to
be distributed with the libwww-perl library.

The following differences exist compared to the C&lt;URI&gt; class interface:

=over 3

=item *

The URI::URL module exports the url() function as an alternate
constructor interface.

=item *

The constructor takes an optional $base argument.  The C&lt;URI::URL&gt;
class is a subclass of C&lt;URI::WithBase&gt;.

=item *

The URI::URL-&gt;newlocal class method is the same as URI::file-&gt;new_abs.

=item *

URI::URL::strict(1)

=item *

$url-&gt;print_on method

=item *

$url-&gt;crack method

=item *

$url-&gt;full_path: same as ($uri-&gt;abs_path || "/")

=item *

$url-&gt;netloc: same as $uri-&gt;authority

=item *

$url-&gt;epath, $url-&gt;equery: same as $uri-&gt;path, $uri-&gt;query

=item *

$url-&gt;path and $url-&gt;query pass unescaped strings.

=item *

$url-&gt;path_components: same as $uri-&gt;path_segments (if you don't
consider path segment parameters)

=item *

$url-&gt;params and $url-&gt;eparams methods

=item *

$url-&gt;base method.  See L&lt;URI::WithBase&gt;.

=item *

$url-&gt;abs and $url-&gt;rel have an optional $base argument.  See
L&lt;URI::WithBase&gt;.

=item *

$url-&gt;frag: same as $uri-&gt;fragment

=item *

$url-&gt;keywords: same as $uri-&gt;query_keywords

=item *

$url-&gt;localpath and friends map to $uri-&gt;file.

=item *

$url-&gt;address and $url-&gt;encoded822addr: same as $uri-&gt;to for mailto URI

=item *

$url-&gt;groupart method for news URI

=item *

$url-&gt;article: same as $uri-&gt;message

=back



=head1 SEE ALSO

L&lt;URI&gt;, L&lt;URI::WithBase&gt;

=head1 COPYRIGHT

Copyright 1998-2000 Gisle Aas.

=cut
</pre></body></html>