File Coverage

blib/lib/Plack/Middleware/IIS6ScriptNameFix.pm
Criterion Covered Total %
statement 18 18 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 3 3 100.0
pod 1 1 100.0
total 24 27 88.8


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