diff options
author | Gisle Aas <gisle@aas.no> | 2012-07-31 23:05:31 +0200 |
---|---|---|
committer | Gisle Aas <gisle@aas.no> | 2012-07-31 23:05:48 +0200 |
commit | 3dd72ded7f043a4f6973781fe594722e2e95f491 (patch) | |
tree | 7e6b30185a82d2b4a4fe36c310692bb1b99d2ec7 | |
parent | 4a83898b61f87f1a9a27dfd262ff8f54f15ccd3e (diff) | |
download | uri-3dd72ded7f043a4f6973781fe594722e2e95f491.tar.gz |
Singleton attributes should't return empty listsbaserock/xfce-buildbaserock/morph
It should be possible to set up an array with
{ USER => $url->user, PASSWORD => $url->password }
without having to worry what $url->user and $url->password
will return empty lists when the element isn't present.
-rw-r--r-- | URI.pm | 8 | ||||
-rw-r--r-- | URI/URL.pm | 2 | ||||
-rw-r--r-- | URI/_generic.pm | 3 | ||||
-rw-r--r-- | URI/_ldap.pm | 4 | ||||
-rw-r--r-- | URI/_userpass.pm | 6 | ||||
-rw-r--r-- | URI/news.pm | 2 | ||||
-rw-r--r-- | URI/pop.pm | 4 |
7 files changed, 15 insertions, 14 deletions
@@ -131,7 +131,7 @@ sub implementor # Try to load it eval "require $ic"; die $@ if $@ && $@ !~ /Can\'t locate.*in \@INC/; - return unless @{"${ic}::ISA"}; + return undef unless @{"${ic}::ISA"}; } $ic->_init_implementor($scheme); @@ -163,7 +163,7 @@ sub _scheme my $self = shift; unless (@_) { - return unless $$self =~ /^($scheme_re):/o; + return undef unless $$self =~ /^($scheme_re):/o; return $1; } @@ -193,7 +193,7 @@ sub _scheme sub scheme { my $scheme = shift->_scheme(@_); - return unless defined $scheme; + return undef unless defined $scheme; lc($scheme); } @@ -239,7 +239,7 @@ sub fragment { my $self = shift; unless (@_) { - return unless $$self =~ /\#(.*)/s; + return undef unless $$self =~ /\#(.*)/s; return $1; } @@ -105,7 +105,7 @@ sub eparams { my $self = shift; my @p = $self->path_segments; - return unless ref($p[-1]); + return undef unless ref($p[-1]); @p = @{$p[-1]}; shift @p; join(";", @p); diff --git a/URI/_generic.pm b/URI/_generic.pm index 979087b..d332756 100644 --- a/URI/_generic.pm +++ b/URI/_generic.pm @@ -148,7 +148,8 @@ sub abs my $abs = $base->clone; my $query = $self->query; $abs->query($query) if defined $query; - $abs->fragment($self->fragment); + my $fragment = $self->fragment; + $abs->fragment($fragment) if defined $fragment; return $abs; } diff --git a/URI/_ldap.pm b/URI/_ldap.pm index d767364..1de7a6c 100644 --- a/URI/_ldap.pm +++ b/URI/_ldap.pm @@ -47,7 +47,7 @@ sub attributes { sub _scope { my $self = shift; my $old = _ldap_elem($self,1, @_); - return unless defined wantarray && defined $old; + return undef unless defined wantarray && defined $old; uri_unescape($old); } @@ -60,7 +60,7 @@ sub scope { sub _filter { my $self = shift; my $old = _ldap_elem($self,2, @_); - return unless defined wantarray && defined $old; + return undef unless defined wantarray && defined $old; uri_unescape($old); # || "(objectClass=*)"; } diff --git a/URI/_userpass.pm b/URI/_userpass.pm index a0361ae..87d7fb5 100644 --- a/URI/_userpass.pm +++ b/URI/_userpass.pm @@ -21,7 +21,7 @@ sub user $self->userinfo("$new$pass"); } } - return unless defined $info; + return undef unless defined $info; $info =~ s/:.*//; uri_unescape($info); } @@ -43,8 +43,8 @@ sub password $self->userinfo("$user:$new"); } } - return unless defined $info; - return unless $info =~ s/^[^:]*://; + return undef unless defined $info; + return undef unless $info =~ s/^[^:]*://; uri_unescape($info); } diff --git a/URI/news.pm b/URI/news.pm index 1ffb419..1c1a385 100644 --- a/URI/news.pm +++ b/URI/news.pm @@ -61,7 +61,7 @@ sub message Carp::croak("Message must contain '\@'") unless $_[0] =~ /\@/; } my $old = $self->_group(@_); - return unless $old =~ /\@/; + return undef unless $old =~ /\@/; return $old; } @@ -31,7 +31,7 @@ sub user } } - return unless defined $old; + return undef unless defined $old; $old =~ s/;.*//; return uri_unescape($old); } @@ -59,7 +59,7 @@ sub auth } - return unless defined $old; + return undef unless defined $old; $old =~ s/^[^;]*//; return uri_unescape($1) if $old =~ /;auth=(.*)/i; return; |