-
-
Save anonymous/b013d2642641c1d38de9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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