summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-09-02 12:10:09 -0500
committerJesse Luehrs <doy@tozt.net>2010-09-02 12:10:09 -0500
commitfcb937cc7d38451b532c195a4f5a197fa6846cbb (patch)
tree6a2c4ee7448781d71a90e1c10a8df0924eb769d8
parentb7cb4fdb82c69ef990c86cee8ec892c370affa0f (diff)
downloadplack-middleware-auth-htpasswd-fcb937cc7d38451b532c195a4f5a197fa6846cbb.tar.gz
plack-middleware-auth-htpasswd-fcb937cc7d38451b532c195a4f5a197fa6846cbb.zip
split m{/}, '/' doesn't do what i want (it returns undef)
-rw-r--r--lib/Plack/Middleware/Auth/Htpasswd.pm12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Plack/Middleware/Auth/Htpasswd.pm b/lib/Plack/Middleware/Auth/Htpasswd.pm
index ff46005..8436912 100644
--- a/lib/Plack/Middleware/Auth/Htpasswd.pm
+++ b/lib/Plack/Middleware/Auth/Htpasswd.pm
@@ -101,12 +101,14 @@ sub authenticate {
return $self->_check_password($self->file, $user, $pass)
if defined $self->file;
- my $req = Plack::Request->new($env);
+ my $path = Plack::Request->new($env)->path;
my $dir = Path::Class::Dir->new($self->file_root);
- my @htpasswd = reverse
- map { $_->file('.htpasswd')->stringify }
- map { $dir = $dir->subdir($_) }
- split m{/}, $req->path;
+ my @htpasswd = $path ne '/'
+ ? reverse
+ map { $_->file('.htpasswd')->stringify }
+ map { $dir = $dir->subdir($_) }
+ split m{/}, $path
+ : ($dir->file('.htpasswd')->stringify);
for my $htpasswd (@htpasswd) {
next unless -f $htpasswd && -r _;