Skip to content

Commit

Permalink
Normalize github issue urls before attempting match
Browse files Browse the repository at this point in the history
  • Loading branch information
rwstauner authored and Vagrant dev user noc@metacpan.org committed May 14, 2015
1 parent c55e63b commit f34c13b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/MetaCPAN/Web/Model/ReleaseInfo.pm
Expand Up @@ -196,7 +196,8 @@ sub normalize_issues {
# source as the url specified in the resources.
if (
# If the specified url matches the source we got our counts from...
$issues->{url} eq $bugs->{source}
$self->normalize_issue_url( $issues->{url} ) eq
$self->normalize_issue_url( $bugs->{source} )

# or if both of them look like rt.
or all {m{^https?://rt\.cpan\.org(/|$)}}
Expand All @@ -210,5 +211,13 @@ sub normalize_issues {
return $issues;
}
sub normalize_issue_url {
local $_ = $_[1];
s{^https?:// (?:www\.)? ( github\.com / ([^/]+) / ([^/]+) ) (.*)$}{https://$1}x;

return $_;
}

__PACKAGE__->meta->make_immutable;
1;
18 changes: 18 additions & 0 deletions t/model/release-info.t
Expand Up @@ -228,6 +228,24 @@ subtest 'normalize_issues' => sub {
'no resources: rt url; counts from old source: no count'
);

foreach my $url (
qw(
https://github.com/user/repo
http://github.com/user/repo
https://github.com/user/repo/issues
http://www.github.com/user/repo/issues
https://www.github.com/user/repo/tree
)
)
{
normalize_issues_ok(
bugtracker( web => $url ),
{ source => 'https://github.com/user/repo', active => 3 },
{ url => $url, active => 3 },
"github variation ($url) matches: specified url and count",
);
}

};

done_testing;

0 comments on commit f34c13b

Please sign in to comment.