Skip to content

Commit

Permalink
Fixed a bug where URLMap for / gets 404 when a pattern match happenes
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Nov 26, 2009
1 parent bf711b5 commit 0eab4e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Plack/App/URLMap.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ sub to_app {
next unless not defined $host or next unless not defined $host or
$http_host eq $host or $http_host eq $host or
$server_name eq $host; $server_name eq $host;
next unless $path =~ s!\Q$location\E!!; next unless $location eq '' or $path =~ s!\Q$location\E!!;
next unless $path eq '' or $path =~ m!/!; next unless $path eq '' or $path =~ m!/!;


local $env->{PATH_INFO} = $path; local $env->{PATH_INFO} = $path;
Expand Down
6 changes: 6 additions & 0 deletions t/Plack-Middleware/urlmap.t
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ test_psgi app => $app, client => sub {


$res = $cb->(GET "http://bar.example.com/foo"); $res = $cb->(GET "http://bar.example.com/foo");
is $res->content, 'app4||/foo'; is $res->content, 'app4||/foo';

# Fix a bug where $location eq ''
$_ = "bar"; /bar/;
$res = $cb->(GET "http://localhost/");
is $res->content, 'app1||/';

}; };


done_testing; done_testing;

0 comments on commit 0eab4e2

Please sign in to comment.