Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that there's only one file before redirecting
it was catching when there was only one dist. fixes #1226.
- Loading branch information
Showing
2 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,11 +55,25 @@ sub index : Path { | |
my $authors = $c->model('API::Author')->search( $query, $from ); | ||
( $results, $authors ) = ( $results->recv, $authors->recv ); | ||
|
||
# The "total" is actually "total distributions". | ||
if ( $results->{total} == 1 ) { | ||
my $module_name | ||
= $results->{results}->[0]->[0]->{module}->[0]->{name}; | ||
$c->res->redirect("/pod/$module_name"); | ||
$c->detach; | ||
my $dist_files = $results->{results}->[0]; | ||
|
||
# There may be more than one file per dist. | ||
if ( @$dist_files == 1 ) { | ||
|
||
# FIXME: What's the right incantation for this? | ||
# Is module name better than documentation? | ||
# We may need to check indexed (in which case we need to make | ||
# sure it's actually a boolean). | ||
my $module_name = $dist_files->[0]->{module}->[0]->{name} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rwstauner
Author
Contributor
|
||
|| $dist_files->[0]->{documentation}; | ||
|
||
if ($module_name) { | ||
$c->res->redirect("/pod/$module_name"); | ||
$c->detach; | ||
} | ||
} | ||
} | ||
elsif ( !$results->{total} && !$authors->{total} ) { | ||
my $suggest = $query; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Doesn't this make the assumption that the first package declaration in the file is the one we're looking for?