Skip to content

Commit

Permalink
added empty path test
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 8, 2014
1 parent 611cff8 commit 609c8d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/Mojo/Path.pm
Expand Up @@ -43,10 +43,7 @@ sub clone {
return $clone;
}

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

sub leading_slash { shift->_parse(leading_slash => @_) }

Expand Down Expand Up @@ -87,8 +84,7 @@ sub to_dir {

sub to_route {
my $clone = shift->clone;
my $route = join '/', @{$clone->parts};
return "/$route" . ($clone->trailing_slash ? '/' : '');
return '/' . join '/', @{$clone->parts}, $clone->trailing_slash ? '' : ();
}

sub to_string {
Expand Down
1 change: 1 addition & 0 deletions t/mojo/path.t
Expand Up @@ -19,6 +19,7 @@ ok $path->trailing_slash, 'has trailing slash';
$path = Mojo::Path->new;
is $path->to_string, '', 'no path';
is $path->to_abs_string, '/', 'right absolute path';
is $path->to_route, '/', 'right route';

# Advanced
$path = Mojo::Path->new('/AZaz09-._~!$&\'()*+,;=:@');
Expand Down

0 comments on commit 609c8d9

Please sign in to comment.