sub match {
my ( $self, $c, $path ) = @_;
- return if $path =~ m!/!; # Not at root yet, wait for it ...
+ return if $path ne ''; # Not at root yet, wait for it ...
my $result = ( $c->get_actions( 'default', $c->req->path ) )[-1];
# Find default on namespace or super
$path =~ s!^/!!;
$path = '/' unless length $path;
$path = URI->new($path)->canonical;
+ $path =~ s{(?<=[^/])/+\z}{};
$self->_paths->{$path} = [
sort { $a <=> $b } ($action, @{ $self->_paths->{$path} || [] })
DESCEND: while (@path) {
$path = join '/', @path;
- $path =~ s#^/##;
-
- $path = '' if $path eq '/'; # Root action
+ $path =~ s#^/+##;
# Check out dispatch types to see if any will handle the path at
# this level
}
return reverse grep { defined } @containers, $self->_container_hash->{''};
-
- #return (split '/', $namespace); # isnt this more clear?
- my @parts = split '/', $namespace;
}
=head2 $self->uri_for_action($action, \@captures)
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
-use Test::More tests => 3*$iters;
+use Test::More tests => 6*$iters;
use Catalyst::Test 'TestAppIndexDefault';
sub run_tests {
is(get('/indexchained'), 'index_chained', ':Chained overrides index');
is(get('/indexprivate'), 'index_private', 'index : Private still works');
+
+# test :Path overriding default
is(get('/one_arg'), 'path_one_arg', ':Path overrides default');
+ is(get('/one_arg/foo/bar'), 'default', 'default still works');
+
+# now the same thing with a namespace, and a trailing / on the :Path
+ is(get('/default/one_arg'), 'default_path_one_arg',
+ ':Path overrides default');
+ is(get('/default/one_arg/foo/bar'), 'default_default',
+ 'default still works');
}