: [] );
$path = $c->dispatcher->uri_for_action($path, $captures);
return undef unless defined($path);
+ $path = '/' if $path eq '';
}
# massage namespace, empty if absolute path
$captures ||= [];
foreach my $dispatch_type ( @{ $self->dispatch_types } ) {
my $uri = $dispatch_type->uri_for_action( $action, $captures );
- return $uri if defined($uri);
+ return( $uri eq '' ? '/' : $uri )
+ if defined($uri);
}
return undef;
}
sub end :Private {
my ($self, $c) = @_;
+ return if $c->stash->{no_end};
my $out = join('; ', map { join(', ', @$_) }
($c->req->captures, $c->req->args));
$c->res->body($out);
#
sub cross2 :PathPart('end') :Chained('/action/chained/bar/cross1') :Args(1) { }
+#
+# Create a uri to the root index
+#
+sub to_root : Chained('/') PathPart('action/chained/to_root') {
+ my ( $self, $c ) = @_;
+ my $uri = $c->uri_for(
+ $c->controller('Root')->action_for('chain_root_index') );
+ $c->res->body( "URI:$uri" );
+ $c->stash->{no_end}++;
+}
+
1;
__PACKAGE__->config->{namespace} = '';
+sub chain_root_index : Chained('/') PathPart('') Args(0) { }
+
1;
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; }
-use Test::More tests => 101*$iters;
+use Test::More tests => 103*$iters;
use Catalyst::Test 'TestApp';
if ( $ENV{CAT_BENCHMARK} ) {
}
#
+ # Tests that an uri_for to a chained root index action
+ # returns the right value.
+ #
+ {
+ ok( my $response = request(
+ 'http://localhost/action/chained/to_root' ),
+ 'uri_for with chained root action as arg' );
+ is( $response->content,
+ 'URI:http://localhost/',
+ 'Correct URI generated' );
+ }
+
+ #
# Test interception of recursive chains. This test was added because at
# one point during the :Chained development, Catalyst used to hang on
# recursive chains.