File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 27
27
say $response -> code;
28
28
if ($response -> is_success) {
29
29
my $module = decode_json $response -> content;
30
+ _normalize_module($module );
30
31
push @modules , $module ;
31
32
my $name = $module -> {name };
32
33
if ($name =~ m { [/\\ ]} || $name =~ m {\.\. } ) {
57
58
open $fh , ' >' , File::Spec-> catfile($OUTDIR , ' errors.json' );
58
59
print $fh encode_json \@errors ;
59
60
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
+ }
You can’t perform that action at this time.
0 commit comments