Skip to content

Commit

Permalink
improved url_escape performance slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 2, 2014
1 parent 95c222f commit fb1d3ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -3,6 +3,7 @@
- Added links method to Mojo::Message.
- Improved split_header function in Mojo::Util to handle more formats with
an optional callback.
- Improved url_escape performance slightly.
- Fixed bug where ojo would sometimes die silently.

5.23 2014-07-31
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Util.pm
Expand Up @@ -328,8 +328,8 @@ sub unquote {

sub url_escape {
my ($str, $pattern) = @_;
$pattern ||= '^A-Za-z0-9\-._~';
$str =~ s/([$pattern])/sprintf('%%%02X',ord($1))/ge;
if ($pattern) { $str =~ s/([$pattern])/sprintf('%%%02X',ord($1))/ge }
else { $str =~ s/([^A-Za-z0-9\-._~])/sprintf('%%%02X',ord($1))/ge }
return $str;
}

Expand Down

0 comments on commit fb1d3ae

Please sign in to comment.