| 1 | 6 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # ABSTRACT: Mojolicious plugin for autoindex function at static resource | ||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | package Mojolicious::Plugin::AutoIndex; | ||||||||||||||||||||
| 7 | { | ||||||||||||||||||||
| 8 | 6 | $Mojolicious::Plugin::AutoIndex::VERSION = '0.0006'; | |||||||||||||||||||
| 9 | } | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 6 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 6 | my $config = { index => [qw/index.html index.htm/] }; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 5 | ▶ | sub register { | ||||||||||||||||||
|
Subroutine
register: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 17 | 5 | my ( $self, $app, $conf ) = @_; | |||||||||||||||||||
| 18 | 5 | ▶ | $config->{index} = $conf->{index} if $conf->{index}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | 5 | ▶ | return unless @{ $config->{index} }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | $app->hook( | ||||||||||||||||||||
| 21 | 8 | ▶ | before_dispatch => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||
| 22 | 8 | my $c = shift; | |||||||||||||||||||
| 23 | 8 | ▶ | my $path = $c->stash('path') // $c->req->url->path->to_string; | ||||||||||||||||||
|
Condition33%1/3
$c->stash("path") // $c->req->url->path->to_string
MC/DC0%0/2
$c->stash("path") // $c->req->url->path->to_string
$c->stash("path")
$c->req->url->path->to_string
Truth table33%1/3
A // B
A= $c->stash("path")B= $c->req->url->path->to_string
| |||||||||||||||||||||
| 24 | 8 | ▶ | return unless $path =~ m!/$!; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | 5 | my $sv_path = $c->stash('path'); | |||||||||||||||||||
| 26 | 5 | foreach ( @{ $config->{index} } ) { | |||||||||||||||||||
| 27 | 5 | $c->stash->{path} = $path . $_; | |||||||||||||||||||
| 28 | 5 | ▶ | if ( $app->static->dispatch($c) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 3 | $c->stash->{path} = $sv_path; | |||||||||||||||||||
| 30 | 3 | return $app->plugins->emit_hook( after_static => $c ); | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | 2 | $c->stash->{path} = $sv_path; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | 5 | ); | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 6 | 1; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | __END__ | ||||||||||||||||||||