Skip to content

Commit

Permalink
the trailing slash is always optional
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 9, 2013
1 parent adea1fd commit 933f61d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,4 +1,7 @@

4.14 2013-06-10
- Improved url_for performance slightly.

4.13 2013-06-09
- Replaced ua method in Mojolicious::Controller with a helper.
- Fixed url_for support for absolute URLs without scheme or authority.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -41,7 +41,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Top Hat';
our $VERSION = '4.13';
our $VERSION = '4.14';

sub AUTOLOAD {
my $self = shift;
Expand Down
6 changes: 0 additions & 6 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -402,12 +402,6 @@ sub url_for {
else {
my ($generated, $ws) = $self->match->path_for($target, @_);
$path->parse($generated) if $generated;

# Fix trailing slash
$path->trailing_slash(1)
if (!$target || $target eq 'current') && $req->url->path->trailing_slash;

# Fix scheme for WebSockets
$base->scheme($base->protocol eq 'https' ? 'wss' : 'ws') if $ws;
}

Expand Down
9 changes: 4 additions & 5 deletions t/mojolicious/lite_app.t
Expand Up @@ -39,7 +39,8 @@ app->types->type(txt => 'text/plain;charset=UTF-8');

get '/☃' => sub {
my $self = shift;
$self->render(text => $self->url_for . $self->url_for('current'));
$self->render(
text => $self->url_for . $self->url_for({}) . $self->url_for('current'));
};

get '/uni/aäb' => sub {
Expand Down Expand Up @@ -443,10 +444,8 @@ is $t->app, app->commands->app, 'applications are equal';
is $t->app->moniker, 'lite_app', 'right moniker';

# Unicode snowman
$t->get_ok('/☃')->status_is(200)->content_is('/%E2%98%83/%E2%98%83');

# Unicode snowman with trailing slash
$t->get_ok('/☃/')->status_is(200)->content_is('/%E2%98%83//%E2%98%83/');
$t->get_ok('/☃')->status_is(200)
->content_is('/%E2%98%83/%E2%98%83/%E2%98%83');

# Umlaut
$t->get_ok('/uni/aäb')->status_is(200)->content_is('/uni/a%C3%A4b');
Expand Down

0 comments on commit 933f61d

Please sign in to comment.