diff options
author | Joenio Costa <joenio@colivre.coop.br> | 2016-01-24 00:21:31 -0200 |
---|---|---|
committer | Olaf Alders <olaf@wundersolutions.com> | 2023-04-29 16:32:23 +0200 |
commit | 30569f15d9aa3a9548bad71e4172d7639f4af372 (patch) | |
tree | 8bf7f330f60b8c7ae5d7d92bb0d2018c751191eb | |
parent | 85253786118786f88c52ffcf3fbf34c3e721d953 (diff) | |
download | uri-30569f15d9aa3a9548bad71e4172d7639f4af372.tar.gz |
remove colon from pair "user:pass" if has no password
(closes github issue #13)
-rw-r--r-- | lib/URI/_userpass.pm | 4 | ||||
-rw-r--r-- | t/userpass.t | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/URI/_userpass.pm b/lib/URI/_userpass.pm index 1cef8f5..f422038 100644 --- a/lib/URI/_userpass.pm +++ b/lib/URI/_userpass.pm @@ -39,8 +39,8 @@ sub password my $user = defined($info) ? $info : ""; $user =~ s/:.*//; - if (!defined($new) && !length($user)) { - $self->userinfo(undef); + if (!defined($new)) { + $self->userinfo($user || undef); } else { $new = "" unless defined($new); $new =~ s/%/%25/g; diff --git a/t/userpass.t b/t/userpass.t new file mode 100644 index 0000000..b18aa3d --- /dev/null +++ b/t/userpass.t @@ -0,0 +1,12 @@ +use strict; +use warnings; + +print "1..1\n"; + +use URI; + +my $uri = URI->new("rsync://foo:bar\@example.com"); +$uri->password(undef); + +print "not " if $uri->as_string =~ /foo:\@example.com/; +print "ok 1\n"; |