Permalink
Browse files

parsing path at the first step

  • Loading branch information...
1 parent f85c893 commit 3eb6ff2b86ae871e642382a87a2d73195a868275 Zbigniew Lukasiak committed Dec 3, 2010
@@ -42,7 +42,7 @@ sub record_action {
return $res;
}
return DvdDatabase::Controller::Dvd::Record->handle(
- path => $action,
+ path => [ $action ],
app => $self->app,
env => $self->env,
self_url => $self->self_url . "record/$id/",
@@ -21,7 +21,6 @@ for my $controller( qw/DvdSimpleUrl/ ){
$res = $cb->(GET "/$controller");
like( $res->content, qr/Jurassic Park II/ );
$res = $cb->(POST "/$controller/5/edit", [ name => 'Not Jurassic Park', owner => 1 ] );
- warn $res->content;
ok( $res->is_redirect, 'Redirect after POST' );
$res = $cb->(GET $res->header('Location'));
like( $res->content, qr/Not Jurassic Park/ );
View
@@ -28,8 +28,9 @@ sub handle {
my $c_class = find_nested( '', $self->controller_search_path );
$path =~ s{^/}{};
die 'Cannot find root controller' if !$c_class;
+ my @parts = split /\//, $path;
my $out = $c_class->handle(
- path => $path,
+ path => [ @parts ],
app => $self,
env => $env,
self_url => '/',
@@ -52,8 +52,7 @@ sub handle {
my ( $class, %args ) = @_;
my $path = delete $args{path};
my $self = $class->new( %args );
- my @parts = split /\//, $path;
- return $self->local_dispatch( @parts );
+ return $self->local_dispatch( @$path );
};
1;
@@ -17,10 +17,9 @@ sub handle {
my ( $class, %args ) = @_;
my $path = delete $args{path};
my $self = $class->new( %args );
- my @parts = split /\//, $path;
- my $out = $self->local_dispatch( @parts );
- return $out if defined($out);
- my( $path_part, $new_path ) = ( $path =~ qr{^([^/]*)/?(.*)} );
+ my $out = $self->local_dispatch( @$path );
+ return $out if defined( $out );
+ my $path_part = shift @$path;
$path_part =~ s/::|'//g if defined( $path_part );
return if !length( $path_part );
my $controller_class = find_nested( $class->_self_path . $path_part, $args{app}->controller_search_path );
@@ -31,7 +30,7 @@ sub handle {
warn qq{Dispatching to "$controller_class"\n} if $self->DEBUG;
return $controller_class->handle(
%args,
- path => $new_path,
+ path => $path,
self_url => $args{self_url} . $path_part . '/',
);
}

0 comments on commit 3eb6ff2

Please sign in to comment.