Skip to content

Commit 00c7478

Browse files
committed
Normalize source urls
1 parent be1540f commit 00c7478

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

server/updatelist.pl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
say $response->code;
2828
if ($response->is_success) {
2929
my $module = decode_json $response->content;
30+
_normalize_module($module);
3031
push @modules, $module;
3132
my $name = $module->{name};
3233
if ($name =~ m{[/\\]} || $name =~ m{\.\.}) {
@@ -57,3 +58,23 @@
5758
open $fh, '>', File::Spec->catfile($OUTDIR, 'errors.json');
5859
print $fh encode_json \@errors;
5960
close $fh;
61+
62+
sub _normalize_module {
63+
my $module = shift;
64+
65+
for ( qw/source-url repo-url/ ) {
66+
next unless defined $module->{ $_ };
67+
_normalize_source_url( $module->{ $_ } );
68+
}
69+
70+
_normalize_source_url( $module->{support}{source} )
71+
if defined $module->{support} and defined $module->{support}{source};
72+
}
73+
sub _normalize_source_url {
74+
for ( @_ ) {
75+
next unless defined;
76+
s/^\s+|\s+$//g;
77+
$_ .= '.git' if m{^git://} and not m{\.git$};
78+
$_ .= '/' if m{^https?://} and not m{/$} ;
79+
}
80+
}

0 commit comments

Comments
 (0)