Skip to content

Commit

Permalink
fixed another MIME type bug in Mojolicious::Static
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 9, 2014
1 parent 2734ce6 commit 6a98983
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Mojolicious/Static.pm
Expand Up @@ -53,8 +53,8 @@ sub serve {
my ($self, $c, $rel) = @_;
return undef unless my $asset = $self->file($rel);
my $types = $c->app->types;
$c->res->headers->content_type(
$types->type($rel =~ /\.(\w+)$/ ? $1 : 'txt'));
my $type = $rel =~ /\.(\w+)$/ ? $types->type($1) : undef;
$c->res->headers->content_type($type || $types->type('txt'));
return !!$self->serve_asset($c, $asset);
}

Expand Down
3 changes: 2 additions & 1 deletion t/mojolicious/lite_app.t
Expand Up @@ -757,7 +757,8 @@ $t->get_ok('/inline/ep/partial')->status_is(200)
->content_is("♥just ♥\nworks!\n");

# Render static file outside of public directory
$t->get_ok('/source')->status_is(200)->header_isnt('X-Missing' => 1)
$t->get_ok('/source')->status_is(200)
->content_type_is('text/plain;charset=UTF-8')->header_isnt('X-Missing' => 1)
->content_like(qr!get_ok\('/source!);

# File does not exist
Expand Down

0 comments on commit 6a98983

Please sign in to comment.