X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FWeb%2FDispatch.pm;h=69df55498eb927cbd5c6d93ccd60e0f71ac7afc6;hb=59ccc1e85596c73f96fce832d900fe72a764f230;hp=9fc44dd5985e451a19c3871081048f0ac5876b6d;hpb=e4c7f3b48593ccf005887a491adfe04991639a83;p=catagits%2FWeb-Simple.git diff --git a/lib/Web/Dispatch.pm b/lib/Web/Dispatch.pm index 9fc44dd..69df554 100644 --- a/lib/Web/Dispatch.pm +++ b/lib/Web/Dispatch.pm @@ -33,7 +33,7 @@ sub call { sub _dispatch { my ($self, $env, @match) = @_; - while (my $try = shift @match) { + while (defined(my $try = shift @match)) { return $try if ref($try) eq 'ARRAY'; if (ref($try) eq 'HASH') { @@ -107,16 +107,12 @@ sub _to_try { my ($self, $try, $more) = @_; if (ref($try) eq 'CODE') { if (defined(my $proto = prototype($try))) { - $self->_construct_node( - match => $self->_parser->parse($proto), run => $try - )->to_app; + $self->_construct_node( match=> $proto, run => $try )->to_app; } else { $try } } elsif (!ref($try) and ref($more->[0]) eq 'CODE') { - $self->_construct_node( - match => $self->_parser->parse($try), run => shift(@$more) - )->to_app; + $self->_construct_node( match => $try, run => shift(@$more) )->to_app; } elsif (blessed($try) && $try->can('to_app')) { $try->to_app; } else { @@ -126,6 +122,7 @@ sub _to_try { sub _construct_node { my ($self, %args) = @_; + $args{match} = $self->_parser->parse( $args{match} ); $self->node_class->new({ %{$self->node_args}, %args }); }