Navigation Menu

Skip to content

Commit

Permalink
fixed rendering bug in Mojo::URL
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 14, 2013
1 parent 44d23d9 commit 485fa33
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Changes
Expand Up @@ -51,7 +51,7 @@
- Improved documentation.
- Improved tests.
- Fixed Perl 5.17.11+ compatibility.
- Fixed a few authority bugs in Mojo::URL.
- Fixed a few authority and rendering bugs in Mojo::URL.
- Fixed layout bugs in Mojolicious::Renderer.
- Fixed support for HEAD request method in Mojo::Server::CGI and
Mojo::Server::PSGI.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/URL.pm
Expand Up @@ -209,7 +209,7 @@ sub to_string {
if (length(my $query = $self->query->to_string)) { $url .= "?$query" }

# Fragment
return $url unless my $fragment = $self->fragment;
return $url unless defined(my $fragment = $self->fragment);
return $url . '#' . url_escape $fragment, '^A-Za-z0-9\-._~!$&\'()*+,;=%:@/?';
}

Expand Down
10 changes: 10 additions & 0 deletions t/mojo/url.t
Expand Up @@ -97,6 +97,16 @@ is $url->query, '_monkeybiz%3B=&_monkey=&23=', 'right query';
is $url->fragment, '23', 'right fragment';
is "$url", 'wss://sri:foobar@example.com:8080?_monkeybiz%3B=&_monkey=&23=#23',
'right format';
$url = Mojo::URL->new('https://example.com/0?0#0');
ok $url->is_abs, 'is absolute';
is $url->scheme, 'https', 'right scheme';
is $url->userinfo, undef, 'no userinfo';
is $url->host, 'example.com', 'right host';
is $url->port, undef, 'no port';
is $url->path, '/0', 'no path';
is $url->query, '0', 'right query';
is $url->fragment, '0', 'right fragment';
is "$url", 'https://example.com/0?0#0', 'right format';

# No authority
$url = Mojo::URL->new('DATA:image/png;base64,helloworld123');
Expand Down

0 comments on commit 485fa33

Please sign in to comment.