Skip to content

Commit

Permalink
fixed path matching bug in Mojo::Path
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 4, 2013
1 parent 3650cf5 commit a8bec13
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -3,6 +3,7 @@
- Improved documentation.
- Improved tests.
- Fixed bug preventing delayed normalization for reused Mojo::Path objects.
- Fixed path matching bug in Mojo::Path.

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 @@ -49,7 +49,7 @@ sub clone {

sub contains {
my ($self, $path) = @_;
return $path eq '/' || $self->to_route =~ m!^$path(?:/|$)!;
return $path eq '/' || $self->to_route =~ m!^\Q$path\E(?:/|$)!;
}

sub leading_slash { shift->_parse(leading_slash => @_) }
Expand Down
3 changes: 3 additions & 0 deletions t/mojo/path.t
Expand Up @@ -296,6 +296,9 @@ $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';
ok $path->contains("/foob\xe4r"), 'contains path';
ok $path->contains("/foob\xe4r/-._~!\$&'()*+,;=:@"), 'contains path';
ok !$path->contains("/foob\xe4r/-._~!\$&'()*+,;=:."), 'does not contain path';
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 Down

0 comments on commit a8bec13

Please sign in to comment.