package Apache2::DirectoryFixup;

use strict;
use warnings FATAL => qw(all);

use Apache2::Const -compile => qw(DIR_MAGIC_TYPE OK DECLINED);
use Apache2::RequestRec;

sub handler {

    my $r = shift;
    if (($r->handler eq 'perl-script' || $r->handler eq 'modperl') &&
        -d $r->filename              &&
        $r->is_initial_req) {
        $r->handler(Apache2::Const::DIR_MAGIC_TYPE);
        return Apache2::Const::OK;
    }

    return Apache2::Const::DECLINED;
}

1;

