Skip to content

Commit

Permalink
Normalize source urls
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Nov 12, 2015
1 parent be1540f commit 00c7478
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server/updatelist.pl
Expand Up @@ -27,6 +27,7 @@
say $response->code;
if ($response->is_success) {
my $module = decode_json $response->content;
_normalize_module($module);
push @modules, $module;
my $name = $module->{name};
if ($name =~ m{[/\\]} || $name =~ m{\.\.}) {
Expand Down Expand Up @@ -57,3 +58,23 @@
open $fh, '>', File::Spec->catfile($OUTDIR, 'errors.json');
print $fh encode_json \@errors;
close $fh;

sub _normalize_module {
my $module = shift;

for ( qw/source-url repo-url/ ) {
next unless defined $module->{ $_ };
_normalize_source_url( $module->{ $_ } );
}

_normalize_source_url( $module->{support}{source} )
if defined $module->{support} and defined $module->{support}{source};
}
sub _normalize_source_url {
for ( @_ ) {
next unless defined;
s/^\s+|\s+$//g;
$_ .= '.git' if m{^git://} and not m{\.git$};
$_ .= '/' if m{^https?://} and not m{/$} ;
}
}

0 comments on commit 00c7478

Please sign in to comment.