Skip to content

Commit

Permalink
the format "0" is problematic
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 28, 2016
1 parent 94b7772 commit 5a96e64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -97,7 +97,7 @@ sub render {
};
my $inline = $options->{inline} = delete $stash->{inline};
$options->{handler} //= $self->default_handler if defined $inline;
$options->{format} = $stash->{format} // $self->default_format;
$options->{format} = $stash->{format} || $self->default_format;

# Data
my $output;
Expand Down Expand Up @@ -167,7 +167,7 @@ sub template_name {
my ($self, $options) = @_;

return undef unless defined(my $template = $options->{template});
return undef unless defined(my $format = $options->{format});
return undef unless my $format = $options->{format};
$template .= ".$format";

$self->warmup unless $self->{templates};
Expand Down
10 changes: 3 additions & 7 deletions t/mojolicious/lite_app.t
Expand Up @@ -46,9 +46,6 @@ is app->build_controller->test->helper, 'Mojolicious::Controller',
# Test renderer
app->renderer->add_handler(dead => sub { die 'renderer works!' });

# Custom format
app->types->type(0 => 'text/zero');

# Rewrite when rendering to string
hook before_render => sub {
my ($c, $args) = @_;
Expand Down Expand Up @@ -439,7 +436,7 @@ get '/redirect/condition/0' => (redirect => 0) => sub {
get '/redirect/condition/1' => (redirect => 1) =>
{text => 'condition works too!'};

get '/url_with' => {template => '0', format => '0'};
get '/url_with' => {template => '0'};

get '/url_with/:foo' => sub {
my $c = shift;
Expand Down Expand Up @@ -1019,8 +1016,7 @@ is b($t->tx->res->body)->url_unescape->decode('UTF-8'), '/captures/♥/☃',
$t->get_ok('/favicon.ico')->status_is(200)->content_is("Not a favicon!\n\n");

# Generate URL with query parameters
$t->get_ok('/url_with?foo=23&bar=24&baz=25')->status_is(200)
->content_type_is('text/zero')->content_is(<<EOF);
$t->get_ok('/url_with?foo=23&bar=24&baz=25')->status_is(200)->content_is(<<EOF);
/url_with?bar=24&baz=25&foo=bar
http://mojolicious.org/test?foo=23&bar=24&baz=25
/test?bar=24&baz=25
Expand Down Expand Up @@ -1123,7 +1119,7 @@ app layout <%= content %><%= app->mode %>
@@ favicon.ico
Not a favicon!
@@ 0.0.ep
@@ 0.html.ep
%== url_with->query([foo => 'bar'])
%== url_with('http://mojolicious.org/test')
%== url_with('/test')->query([foo => undef])
Expand Down

0 comments on commit 5a96e64

Please sign in to comment.