Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

simplify uri_escape

  • Loading branch information...
commit 926cdecd8bdff48c2e901f9e4a4eb61c92a37b40 1 parent c4aa138
@moritz moritz authored
Showing with 6 additions and 12 deletions.
  1. +6 −12 lib/URI/Escape.pm
View
18 lib/URI/Escape.pm
@@ -17,18 +17,12 @@ package URI::Escape {
sub uri_escape($s, Bool :$no_utf8 = False) is export {
return $s unless defined $s;
- $s.subst(:g, rx/<- [!*'()\-._~A..Za..z0..9]>+/,
- -> $escape {
- ($escape.Str.comb.map: {
- ( $no_utf8 || ! 0x80 +& ord($_) ) ?? %escapes{ $_ } !!
- do {
- my $buf = $_.encode;
- for (0 ..^ $buf.elems) {
- sprintf '%%%02X', $buf[ $_ ]
- }
- }
- }).join;
- });
+ $s.subst(:g, rx/<- [!*'()\-._~A..Za..z0..9]>/,
+ {
+ ( $no_utf8 || ! 0x80 +& ord(.Str) ) ?? %escapes{ .Str } !!
+ %escapes{.Str.encode.list>>.chr}.join;
+ }
+ );
}
# todo - automatic invalid UTF-8 detection
Please sign in to comment.
Something went wrong with that request. Please try again.