Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return 404 for invalid path: /release//File-Stat-Convert #3156

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/MetaCPAN/Web/Controller/Release.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package MetaCPAN::Web::Controller::Release;

Check failure on line 1 in lib/MetaCPAN/Web/Controller/Release.pm

View workflow job for this annotation

GitHub Actions / Code Formatting

Linting with perltidy failed

use Moose;
use namespace::autoclean;
Expand Down Expand Up @@ -39,11 +39,18 @@
my ( $self, $c ) = @_;
my ( $author, $release ) = $c->stash->@{qw(author_name release_name)};

$c->stash(
permalinks => 1,
release_info => $c->model( 'ReleaseInfo', full_details => 1 )
->get( $author, $release ),
);
if ( !$author ) {

# /release//File-Stat-Convert and others are never going to match
# do not even try call the API
$c->detach('/not_found');
} else {
$c->stash(
permalinks => 1,
release_info => $c->model( 'ReleaseInfo', full_details => 1 )
->get( $author, $release ),
);
}
$c->forward('view');
}

Expand Down
7 changes: 7 additions & 0 deletions t/controller/release.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use strict;

Check failure on line 1 in t/controller/release.t

View workflow job for this annotation

GitHub Actions / Code Formatting

Linting with perltidy failed
use warnings;
use lib 't/lib';

Expand All @@ -22,6 +22,13 @@
'GET /release/PERLER/DOESNTEXIST' );
is( $res->code, 404, 'code 404' );

ok( $res = $cb->( GET '/release/BRICAS/CPAN-Changes-0.21' ), 'GET /release/BRICAS/CPAN-Changes-0.21' );
is( $res->code, 200, 'code 200' );

# Testing missing author returns 404 not a 500
ok( $res = $cb->( GET '/release//CPAN-Changes-0.21' ), 'GET /release//CPAN-Changes-0.21' );
is( $res->code, 404, 'code 404' );

ok( $res = $cb->( GET '/dist/Moose' ), 'GET /dist/Moose' );
is( $res->code, 200, 'code 200' );

Expand Down
Loading