File Coverage

blib/lib/Plack/Middleware/IIS6ScriptNameFix.pm
Criterion Covered Total %
statement 21 21 100.0
branch 1 2 50.0
condition 3 6 50.0
subroutine 4 4 100.0
pod 1 1 100.0
total 30 34 88.2


line stmt bran cond sub pod time code
1             package Plack::Middleware::IIS6ScriptNameFix;
2              
3 1     1   60973 use strict;
  1         13  
  1         27  
4 1     1   384 use parent 'Plack::Middleware';
  1         283  
  1         5  
5 1     1   38 use Plack::Util::Accessor qw(force);
  1         2  
  1         3  
6              
7             sub call {
8 2     2 1 5 my($self, $env) = @_;
9              
10 2 50 33     5 if ($self->force || ($env->{SERVER_SOFTWARE} && $env->{SERVER_SOFTWARE} =~ /IIS\/[6-9]\.[0-9]/)) {
      66        
11 2         6 my @script_name = split(m!/!, $env->{PATH_INFO});
12 2         24 my @path_translated = split(m!/|\\\\?!, $env->{PATH_TRANSLATED});
13 2         3 my @path_info;
14              
15 2         7 while ($script_name[$#script_name] eq $path_translated[$#path_translated]) {
16 2         3 pop(@path_translated);
17 2         7 unshift(@path_info, pop(@script_name));
18             }
19              
20 2         4 unshift(@path_info, '', '');
21              
22 2         6 $env->{PATH_INFO} = join('/', @path_info);
23 2         6 $env->{SCRIPT_NAME} = join('/', @script_name);
24             }
25              
26 2         7 return $self->app->($env);
27             }
28              
29             1;
30              
31             __END__