Skip to content

Commit

Permalink
fixed bug preventing delayed normalization for reused Mojo::Path objects
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 4, 2013
1 parent b092699 commit 7337ed8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes
@@ -1,6 +1,8 @@

3.89 2013-03-04
- Improved documentation.
- Improved tests.
- Fixed bug preventing delayed normalization for reused Mojo::Path objects.

3.88 2013-03-03
- Improved Mojo::Path to delay normalization as long as possible.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Path.pm
Expand Up @@ -70,7 +70,7 @@ sub merge {
sub parse {
my $self = shift;
$self->{path} = shift;
$self->_parse if $self->{parts};
delete $self->{$_} for qw(leading_slash parts trailing_slash);
return $self;
}

Expand Down
13 changes: 13 additions & 0 deletions t/mojo/path.t
Expand Up @@ -293,6 +293,9 @@ is $path->to_route, '/foo/bar', 'right route';

# Unchanged path
$path = Mojo::Path->new('/foob%E4r/-._~!$&\'()*+,;=:@');
is $path->clone->parts->[0], "foob\xe4r", 'right part';
is $path->clone->parts->[1], '-._~!$&\'()*+,;=:@', 'right part';
is $path->clone->parts->[2], undef, 'no part';
is $path->to_string, '/foob%E4r/-._~!$&\'()*+,;=:@', 'right path';
is $path->to_abs_string, '/foob%E4r/-._~!$&\'()*+,;=:@', 'right absolute path';
is $path->to_route, "/foob\xe4r/-._~!\$&'()*+,;=:@", 'right route';
Expand All @@ -301,6 +304,16 @@ is $path->clone->to_abs_string, '/foob%E4r/-._~!$&\'()*+,;=:@',
'right absolute path';
is $path->clone->to_route, "/foob\xe4r/-._~!\$&'()*+,;=:@", 'right route';

# Reuse path
$path = Mojo::Path->new('/foob%E4r');
is $path->to_string, '/foob%E4r', 'right path';
is $path->parts->[0], "foob\xe4r", 'right part';
is $path->parts->[1], undef, 'no part';
$path->parse('/foob%E4r');
is $path->to_string, '/foob%E4r', 'right path';
is $path->parts->[0], "foob\xe4r", 'right part';
is $path->parts->[1], undef, 'no part';

# Latin-1
$path = Mojo::Path->new->charset('Latin-1')->parse('/foob%E4r');
is $path->parts->[0], 'foobär', 'right part';
Expand Down

0 comments on commit 7337ed8

Please sign in to comment.