Skip to content

Commit

Permalink
Merge pull request #3157 from metacpan/haarg/return-404-missing-author
Browse files Browse the repository at this point in the history
Return 404 for releases missing author, e.g. /release//File-Stat-Convert instead of a 500
  • Loading branch information
haarg authored Aug 25, 2024
2 parents 9059e9d + e61bdd9 commit 7b8abe2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/MetaCPAN/Web/Controller/Release.pm
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package MetaCPAN::Web::Controller::Release;

use Moose;
use namespace::autoclean;
use namespace::autoclean -except => [qw(NonEmptyStr)];
use experimental 'postderef';
use Future ();
use Future ();
use MetaCPAN::Web::Types qw(NonEmptyStr); ## no perlimports

BEGIN { extends 'MetaCPAN::Web::Controller' }

sub root : Chained('/') PathPart('release') CaptureArgs(2) {
sub root : Chained('/') PathPart('release')
CaptureArgs(NonEmptyStr,NonEmptyStr) {
my ( $self, $c, $author, $release ) = @_;

# force consistent casing in URLs
Expand Down
9 changes: 9 additions & 0 deletions t/controller/release.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ test_psgi app, sub {
'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

0 comments on commit 7b8abe2

Please sign in to comment.