summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGisle Aas <gisle@aas.no>2012-07-31 23:05:31 +0200
committerGisle Aas <gisle@aas.no>2012-07-31 23:05:48 +0200
commit3dd72ded7f043a4f6973781fe594722e2e95f491 (patch)
tree7e6b30185a82d2b4a4fe36c310692bb1b99d2ec7
parent4a83898b61f87f1a9a27dfd262ff8f54f15ccd3e (diff)
downloaduri-baserock/xfce-build.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.pm8
-rw-r--r--URI/URL.pm2
-rw-r--r--URI/_generic.pm3
-rw-r--r--URI/_ldap.pm4
-rw-r--r--URI/_userpass.pm6
-rw-r--r--URI/news.pm2
-rw-r--r--URI/pop.pm4
7 files changed, 15 insertions, 14 deletions
diff --git a/URI.pm b/URI.pm
index 091e11f..c8a168e 100644
--- a/URI.pm
+++ b/URI.pm
@@ -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;
}
diff --git a/URI/URL.pm b/URI/URL.pm
index ade2028..75517fa 100644
--- a/URI/URL.pm
+++ b/URI/URL.pm
@@ -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;
}
diff --git a/URI/pop.pm b/URI/pop.pm
index 50b8d6d..7f20b5a 100644
--- a/URI/pop.pm
+++ b/URI/pop.pm
@@ -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;