URI-cpan
view release on metacpan or search on metacpan
lib/URI/cpan.pm view on Meta::CPAN
sub _init {
my $self = shift->SUPER::_init(@_);
my $class = ref($self);
Carp::croak "invalid cpan URI: non-empty query string not supported"
if $self->query;
Carp::croak "invalid cpan URI: non-empty fragment string not supported"
if $self->fragment;
my (undef, @path_parts) = split m{/}, $self->path;
my $type = $path_parts[0];
Carp::croak "invalid cpan URI: do not understand path " . $self->path
unless my $new_class = $type_class{ $type };
bless $self => $new_class;
$self->validate;
return $self;
lib/URI/cpan/author.pm view on Meta::CPAN
use strict;
use warnings;
package URI::cpan::author 1.009;
use parent qw(URI::cpan);
sub validate {
my ($self) = @_;
my ($author, @rest) = split m{/}, $self->_p_rel;
Carp::croak "invalid cpan URI: trailing path elements in $self" if @rest;
Carp::croak "invalid cpan URI: invalid author part in $self"
unless $author =~ m{\A[A-Z]+\z};
}
sub author {
my ($self) = @_;
my ($author) = split m{/}, $self->_p_rel;
return $author;
}
1;
__END__
=pod
=encoding UTF-8
lib/URI/cpan/distfile.pm view on Meta::CPAN
#pod This URL refers to a file in an author directory on the CPAN, and expects the
#pod format AUTHOR/DISTFILE
#pod
#pod =head1 METHODS
#pod
#pod =cut
sub validate {
my ($self) = @_;
my (undef, undef, $author, $filename) = split m{/}, $self->path, 4;
Carp::croak "invalid cpan URI: invalid author part in $self"
unless $author =~ m{\A[A-Z][-0-9A-Z]*\z};
}
#pod =head1 dist_name
#pod
#pod This returns the name of the dist, like F<CGI.pm> or F<Acme-Drunk>.
#pod
#pod =cut
( run in 1.637 second using v1.01-cache-2.11-cpan-71847e10f99 )