Skip to content

Commit

Permalink
fixed a few comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 14, 2013
1 parent 7e9b45a commit b3bdac5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/URL.pm
Expand Up @@ -201,7 +201,7 @@ sub to_string {
my $authority = $self->authority;
$url .= "//$authority" if defined $authority;

# Relative or no path
# Path
my $path = $self->path->to_string;
$url .= !$authority || $path eq '' || $path =~ m!^/! ? $path : "/$path";

Expand Down
38 changes: 19 additions & 19 deletions t/mojo/url.t
Expand Up @@ -327,25 +327,6 @@ is $url->to_abs, 'http://example.com/bar/foo?foo=bar#23',
'right absolute version';
is $url->to_abs->base, 'http://example.com/bar/baz/', 'right base';

# Canonicalize (escaped path)
$url = Mojo::URL->new(
'http://example.com/mojo%2Fg%2B%2B-4%2E2_4%2E2%2E3-2ubuntu7_i386%2Edeb');
ok $url->is_abs, 'is absolute';
is $url->scheme, 'http', 'right scheme';
is $url->userinfo, undef, 'no userinfo';
is $url->host, 'example.com', 'right host';
is $url->port, undef, 'no port';
is $url->path, '/mojo%2Fg%2B%2B-4%2E2_4%2E2%2E3-2ubuntu7_i386%2Edeb',
'right path';
is $url->query, '', 'no query';
is $url->fragment, undef, 'no fragment';
is "$url",
'http://example.com/mojo%2Fg%2B%2B-4%2E2_4%2E2%2E3-2ubuntu7_i386%2Edeb',
'right format';
$url->path->canonicalize;
is "$url", 'http://example.com/mojo/g++-4.2_4.2.3-2ubuntu7_i386.deb',
'right format';

# Clone (advanced)
$url = Mojo::URL->new(
'ws://sri:foobar@example.com:8080/test/index.html?monkey=biz&foo=1#23');
Expand Down Expand Up @@ -708,6 +689,25 @@ is $url->host, 'foo.1.1.1.1.de', 'right host';
$url = Mojo::URL->new('http://1.1.1.1.1.1/');
is $url->host, '1.1.1.1.1.1', 'right host';

# Heavily escaped path
$url = Mojo::URL->new(
'http://example.com/mojo%2Fg%2B%2B-4%2E2_4%2E2%2E3-2ubuntu7_i386%2Edeb');
ok $url->is_abs, 'is absolute';
is $url->scheme, 'http', 'right scheme';
is $url->userinfo, undef, 'no userinfo';
is $url->host, 'example.com', 'right host';
is $url->port, undef, 'no port';
is $url->path, '/mojo%2Fg%2B%2B-4%2E2_4%2E2%2E3-2ubuntu7_i386%2Edeb',
'right path';
is $url->query, '', 'no query';
is $url->fragment, undef, 'no fragment';
is "$url",
'http://example.com/mojo%2Fg%2B%2B-4%2E2_4%2E2%2E3-2ubuntu7_i386%2Edeb',
'right format';
$url->path->canonicalize;
is "$url", 'http://example.com/mojo/g++-4.2_4.2.3-2ubuntu7_i386.deb',
'right format';

# "%" in path
$url = Mojo::URL->new('http://mojolicio.us/100%_fun');
is $url->path->parts->[0], '100%_fun', 'right part';
Expand Down

0 comments on commit b3bdac5

Please sign in to comment.