Permalink
Browse files

Fixed a bug where URLMap for / gets 404 when a pattern match happenes

  • Loading branch information...
1 parent bf711b5 commit 0eab4e2a6573e42a89dd6de51091b1e2b1cc6166 @miyagawa miyagawa committed Nov 26, 2009
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/Plack/App/URLMap.pm
  2. +6 −0 t/Plack-Middleware/urlmap.t
View
@@ -50,7 +50,7 @@ sub to_app {
next unless not defined $host or
$http_host eq $host or
$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!/!;
local $env->{PATH_INFO} = $path;
@@ -52,6 +52,12 @@ test_psgi app => $app, client => sub {
$res = $cb->(GET "http://bar.example.com/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;

0 comments on commit 0eab4e2

Please sign in to comment.