Skip to content

Commit

Permalink
Fix decode when "namespace" component is undef
Browse files Browse the repository at this point in the history
  • Loading branch information
giterlizzi committed Jul 31, 2022
1 parent c4cae36 commit 12446e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Revision history for Perl extension URI::PackageURL.

1.02 2022-07-31
- Fix decode when "namespace" component is undef

1.01 2022-07-26
- Fix documentation and test prerequisite (JSON::PP)

Expand Down
14 changes: 6 additions & 8 deletions lib/URI/PackageURL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use constant DEBUG => $ENV{PURL_DEBUG};

use overload '""' => 'to_string', fallback => 1;

our $VERSION = '1.01';
our $VERSION = '1.02';

our @EXPORT = qw(encode_purl decode_purl);

Expand Down Expand Up @@ -193,7 +193,6 @@ sub from_string {

$s3[1] =~ s{(^\/|\/$)}{};
my @s4 = split('/', $s3[1], 2);

$components{type} = lc $s4[0];


Expand All @@ -204,7 +203,6 @@ sub from_string {
# This is the version

my @s5 = split('@', $s4[1]);

$components{version} = url_decode($s5[1]);


Expand All @@ -216,8 +214,7 @@ sub from_string {
# This is the name

my @s6 = split('/', $s5[0], 2);

$components{name} = url_decode($s6[1]);
$components{name} = (scalar @s6 > 1) ? url_decode($s6[1]) : url_decode($s6[0]);


# Split the remainder on '/'
Expand All @@ -228,9 +225,10 @@ sub from_string {
# Join segments back with a '/'
# This is the namespace

my @s7 = split('/', $s6[0]);

$components{namespace} = join '/', map { url_decode($_) } @s7;
if (scalar @s6 > 1) {
my @s7 = split('/', $s6[0]);
$components{namespace} = join '/', map { url_decode($_) } @s7;
}


return $class->new(%components);
Expand Down

0 comments on commit 12446e2

Please sign in to comment.