Skip to content

Commit

Permalink
fixed another small stringification bug in Mojo::Path
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 12, 2012
1 parent 0f12d1b commit 1ba7ad7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Changes
Expand Up @@ -4,7 +4,7 @@ This file documents the revision history for Perl extension Mojolicious.
- Added merge method to Mojo::Path.
- Improved documentation.
- Improved tests.
- Fixed small stringification bug in Mojo::Path.
- Fixed small stringification bugs in Mojo::Path.

2.95 2012-05-10
- Improved documentation.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Path.pm
Expand Up @@ -88,7 +88,7 @@ sub parse {
sub to_abs_string {
my $self = shift;
my $string = $self->to_string;
return $self->leading_slash ? $string : $string ? "/$string" : '';
return $self->leading_slash ? $string : length($string) ? "/$string" : '';
}

# "How is education supposed to make me feel smarter?
Expand Down
7 changes: 6 additions & 1 deletion t/mojo/path.t
Expand Up @@ -2,7 +2,7 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 206;
use Test::More tests => 210;

# "This is the greatest case of false advertising I’ve seen since I sued the
# movie 'The Never Ending Story.'"
Expand Down Expand Up @@ -53,6 +53,11 @@ is $path->parts->[1], '0', 'right part';
is $path->parts->[2], undef, 'no part';
ok $path->leading_slash, 'has leading slash';
ok !$path->trailing_slash, 'no trailing slash';
$path = Mojo::Path->new('0');
is $path->parts->[0], '0', 'right part';
is $path->parts->[1], undef, 'no part';
is $path->to_string, '0', 'right result';
is $path->to_abs_string, '/0', 'right result';

# Canonicalizing
$path = Mojo::Path->new(
Expand Down

0 comments on commit 1ba7ad7

Please sign in to comment.