URI-Nested

 view release on metacpan or  search on metacpan

lib/URI/Nested.pm  view on Meta::CPAN

    }
    my $uri = URI->new($str, $base);
    return $uri if $uri->isa(__PACKAGE__);

    # Convert to a nested URI and assign the scheme, if needed.
    $uri->scheme($scheme) if $scheme && !$uri->scheme;
    if ( my $nested_class = $class->nested_class ) {
        bless $uri => $nested_class unless $uri->isa($nested_class);
    }

    bless [ $prefix => $uri ] => $class;
}

sub new_abs {
    my ($class, $uri, $base) = @_;
    $uri = URI->new($uri);
    # No change if already have a scheme.
    return $uri if $uri->scheme;
    $base = URI->new($base);
    # Return non-nested absolute.
    return $uri->abs($base) unless $base->isa(__PACKAGE__);

lib/URI/Nested.pm  view on Meta::CPAN

    }
    return $class->_nested_init($scheme, $str);
}

sub _nested_init {
    my ($class, $scheme, $str) = @_;
    my $uri = URI->new($str);
    if ( my $nested_class = $class->nested_class ) {
        bless $uri => $nested_class unless $uri->isa($nested_class);
    }
    bless [ $scheme, $uri ] => $class;
}

sub nested_uri { shift->[1] }

sub scheme {
    my $self = shift;
    return lc $self->[0] unless @_;
    my $new = shift;
    my $old = $self->[0];
    # Cannot change $self from array ref to scalar ref, so reject other schemes.



( run in 0.341 second using v1.01-cache-2.11-cpan-65fba6d93b7 )