Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed url_with to be compatible with url_for
  • Loading branch information
kraih committed Jan 12, 2012
1 parent aec5ac1 commit ea0d9c9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,6 +1,6 @@
This file documents the revision history for Perl extension Mojolicious.

2.44 2012-01-12 00:00:00
2.44 2012-01-13 00:00:00
- Added EXPERIMENTAL url_with method to Mojolicious::Controller.
(diegok, marcus, judofyr, sri)
- Added EXPERIMENTAL support for removing query parmaters while
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -592,8 +592,7 @@ sub url_for {

sub url_with {
my $self = shift;
my $url = $self->req->url->clone;
return @_ ? $self->url_for(@_)->query($url->query) : $url;
return $self->url_for(@_)->query($self->req->url->query->clone);
}

sub write {
Expand Down
12 changes: 6 additions & 6 deletions t/mojolicious/lite_app.t
Expand Up @@ -533,10 +533,10 @@ get '/redirect/condition/1' => (redirect => 1) =>
# GET /url_with
get '/url_with';

# GET /url_with/abs
get '/url_with/abs' => sub {
# GET /url_with/*
get '/url_with/:foo' => sub {
my $self = shift;
$self->render(text => $self->url_with->to_abs);
$self->render(text => $self->url_with(foo => 'bar')->to_abs);
};

# Oh Fry, I love you more than the moon, and the stars,
Expand Down Expand Up @@ -1401,9 +1401,9 @@ http://mojolicio.us/test?foo=23&bar=24&baz=25
/bar/23?bar=24&baz=25&foo=yada
EOF

# GET /url_with/abs
$t->get_ok('/url_with/abs?foo=bar')->status_is(200)
->content_like(qr|http\://localhost\:\d+/url_with/abs\?foo\=bar|);
# GET /url_with/foo
$t->get_ok('/url_with/foo?foo=bar')->status_is(200)
->content_like(qr|http\://localhost\:\d+/url_with/bar\?foo\=bar|);

# User agent timer
$tua->ioloop->one_tick('0.1');
Expand Down

0 comments on commit ea0d9c9

Please sign in to comment.