Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 3, 2013
1 parent 54ea744 commit b8e2157
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions lib/Mojo/Path.pm
Expand Up @@ -49,14 +49,7 @@ sub clone {

sub contains {
my ($self, $path) = @_;

my $parts = $self->new($path)->parts;
for my $part (@{$self->parts}) {
return 1 unless defined(my $try = shift @$parts);
return undef unless $part eq $try;
}

return !@$parts;
return $path eq '/' || $self->to_route =~ m!^$path(/|$)!;
}

sub leading_slash { shift->_lazy(leading_slash => @_) }
Expand All @@ -75,8 +68,8 @@ sub merge {
}

sub parse {
my ($self, $path) = @_;
$self->{path} = $path;
my $self = shift;
$self->{path} = shift;
$self->_parse if $self->{parts};
return $self;
}
Expand Down Expand Up @@ -158,7 +151,9 @@ Mojo::Path - Path
=head1 DESCRIPTION
L<Mojo::Path> is a container for URL paths.
L<Mojo::Path> is a container for URL paths. Note that C<%2F> will be treated
as C</> for security reasons if the path has to be normalized for an
operation.
=head1 ATTRIBUTES
Expand Down Expand Up @@ -245,7 +240,7 @@ Merge paths.
$path = $path->parse('/foo%2Fbar%3B/baz.html');
Parse path. Note that C<%2F> will be treated as C</> for security reasons.
Parse path.
=head2 to_abs_string
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/UserAgent.pm
Expand Up @@ -438,7 +438,7 @@ sub _start {
if ($self->{port} || !$url->is_abs) {
if (my $app = $self->app) { $self->_server->app($app) }
my $base = $self->app_url;
$url = $req->url->scheme($base->scheme)->authority($base->authority)
$url->scheme($base->scheme)->authority($base->authority)
unless $url->is_abs;
}

Expand Down

0 comments on commit b8e2157

Please sign in to comment.