From: Graeme Lawton Date: Sat, 10 Oct 2015 15:28:48 +0000 (+0100) Subject: Args() wasn't being processed as unlimited number of args, due to X-Git-Tag: 5.90102~3^2^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=43b44b3a2ee087f00af6579d3b6ac63f8f645412 Args() wasn't being processed as unlimited number of args, due to attributes->{'Args'} no longer being not defined. Re: 104 --- diff --git a/lib/Catalyst/Action.pm b/lib/Catalyst/Action.pm index fef451d..07f2f32 100644 --- a/lib/Catalyst/Action.pm +++ b/lib/Catalyst/Action.pm @@ -52,7 +52,9 @@ has number_of_args => ( if( ! exists $self->attributes->{Args} ) { # When 'Args' does not exist, that means we want 'any number of args'. return undef; - } elsif(!defined($self->attributes->{Args}[0])) { + } elsif( + !defined($self->attributes->{Args}[0]) || + $self->attributes->{Args}[0] eq '' ) { # When its 'Args' that internal cue for 'unlimited' return undef; } elsif( @@ -138,6 +140,7 @@ has args_constraints => ( return [] unless scalar(@arg_protos); return [] unless defined($arg_protos[0]); + return [] if ($arg_protos[0] eq '' && scalar(@arg_protos) == 1); # If there is only one arg and it looks like a number # we assume its 'classic' and the number is the number of diff --git a/t/lib/TestPath/Controller/Four.pm b/t/lib/TestPath/Controller/Four.pm new file mode 100644 index 0000000..b7426b5 --- /dev/null +++ b/t/lib/TestPath/Controller/Four.pm @@ -0,0 +1,12 @@ +package TestPath::Controller::Four; +use Moose; +use namespace::autoclean; + +BEGIN { extends 'Catalyst::Controller' } + +sub four :Path('') :Args() { + my ( $self, $c ) = @_; + $c->response->body( 'OK' ); +} + +__PACKAGE__->meta->make_immutable; \ No newline at end of file diff --git a/t/path_action_empty_brackets.t b/t/path_action_empty_brackets.t index 415f121..5d100d5 100644 --- a/t/path_action_empty_brackets.t +++ b/t/path_action_empty_brackets.t @@ -4,7 +4,7 @@ use warnings; use FindBin; use lib "$FindBin::Bin/lib"; -use Test::More tests => 9; +use Test::More tests => 12; use Catalyst::Test 'TestPath'; @@ -23,5 +23,8 @@ use Catalyst::Test 'TestPath'; ok( $response->is_success, '"Path(\'\')" - Response Successful 2xx' ); is( $response->content, 'OK', '"Path(\'\')" - Body okay' ); } - - +{ + ok( my $response = request('http://localhost/four'), 'Request' ); + ok( $response->is_success, '"Path(\'\')" - Response Successful 2xx' ); + is( $response->content, 'OK', '"Path() Args()" - Body okay' ); +} \ No newline at end of file