Skip to content

Instantly share code, notes, and snippets.

/-

Created August 18, 2014 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b013d2642641c1d38de9 to your computer and use it in GitHub Desktop.
Save anonymous/b013d2642641c1d38de9 to your computer and use it in GitHub Desktop.
diff --git a/lib/Mojo/Path.pm b/lib/Mojo/Path.pm
index a1684f1..3d5fdfe 100644
--- a/lib/Mojo/Path.pm
+++ b/lib/Mojo/Path.pm
@@ -120,9 +120,11 @@ sub _parse {
my $path = url_unescape delete($self->{path}) // '';
my $charset = $self->charset;
$path = decode($charset, $path) // $path if $charset;
- $self->{leading_slash} = $path =~ s!^/!!;
- $self->{trailing_slash} = $path =~ s!/$!!;
- $self->{parts} = [split '/', $path, -1];
+ $self->{leading_slash}
+ = substr($path, 0, 1) eq '/' && substr($path, 0, 1, '');
+ $self->{trailing_slash}
+ = substr($path, -1, 1) eq '/' && substr($path, -1, 1, '');
+ $self->{parts} = [split '/', $path, -1];
}
return $self->{$name} unless @_;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment