[Catalyst-commits] r6839 -
trunk/Catalyst-Runtime/lib/Catalyst/DispatchType
gbjk at dev.catalyst.perl.org
gbjk at dev.catalyst.perl.org
Wed Sep 5 09:50:04 GMT 2007
Author: gbjk
Date: 2007-09-05 09:50:04 +0100 (Wed, 05 Sep 2007)
New Revision: 6839
Modified:
trunk/Catalyst-Runtime/lib/Catalyst/DispatchType/Chained.pm
Log:
DT::Chained: Fix runtime error if no parts are found.
Modified: trunk/Catalyst-Runtime/lib/Catalyst/DispatchType/Chained.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst/DispatchType/Chained.pm 2007-09-04 20:48:22 UTC (rev 6838)
+++ trunk/Catalyst-Runtime/lib/Catalyst/DispatchType/Chained.pm 2007-09-05 08:50:04 UTC (rev 6839)
@@ -102,7 +102,7 @@
my @parts = split('/', $path);
my ($chain, $captures, $parts) = $self->recurse_match($c, '/', \@parts);
- push @{$c->req->args}, @$parts;
+ push @{$c->req->args}, @$parts if $parts && @$parts;
return 0 unless $chain;
@@ -127,7 +127,7 @@
my ( $self, $c, $parent, $path_parts ) = @_;
my $children = $self->{children_of}{$parent};
return () unless $children;
- my $best_action;
+ my $best_action;
my @captures;
TRY: foreach my $try_part (sort { length($b) <=> length($a) }
keys %$children) {
@@ -157,30 +157,30 @@
my ($actions, $captures, $action_parts) = $self->recurse_match(
$c, '/'.$action->reverse, \@parts
);
- if ($actions && (!$best_action || $#$action_parts < $#{$best_action->{parts}})){
- $best_action = {
- actions => [ $action, @$actions ],
- captures=> [ @captures, @$captures ],
- parts => $action_parts
- };
- }
- }
- else {
+ if ($actions && (!$best_action || $#$action_parts < $#{$best_action->{parts}})){
+ $best_action = {
+ actions => [ $action, @$actions ],
+ captures=> [ @captures, @$captures ],
+ parts => $action_parts
+ };
+ }
+ }
+ else {
{
local $c->req->{arguments} = [ @{$c->req->args}, @parts ];
next TRY_ACTION unless $action->match($c);
}
- if (!$best_action || $#parts < $#{$best_action->{parts}}){
- $best_action = {
- actions => [ $action ],
- captures=> [],
- parts => \@parts
- }
- }
+ if (!$best_action || $#parts < $#{$best_action->{parts}}){
+ $best_action = {
+ actions => [ $action ],
+ captures=> [],
+ parts => \@parts
+ }
+ }
}
}
}
- return @$best_action{qw/actions captures parts /} if $best_action;
+ return @$best_action{qw/actions captures parts /} if $best_action;
return ();
}
More information about the Catalyst-commits
mailing list